• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Viele hassen ihn, manche schwören auf ihn, wir aber möchten unbedingt sehen, welche Bilder Ihr vor Eurem geistigen Auge bzw. vor der Linse Eures iPhone oder iPad sehen könnt, wenn Ihr dieses Wort hört oder lest. Macht mit und beteiligt Euch an unserem Frühjahrsputz ---> Klick

[AS]- FTP alles aus / auf HDD kopieren

  • Ersteller Mitglied 26876
  • Erstellt am

Mitglied 26876

Gast
Hey Leute,

ich frage mich warum mein kleines AppleScript nicht läuft. Es soll lediglich eine FTP Verbindung erstellen (mit Finder einbinden) und dort jede Datei aus dem Verzeichnis / in einen Ordner, mit dem heutigen Datum+1 oder+2, auf meine HDD kopieren.
Er soll 2 Backups pro Tag machen.
So der Fehler am Ganzen heißt so:
Code:
„every item of "[URL="ftp://Volumes:[email protected]"]Volumes:[email protected][/URL]"“ kann nicht gelesen werden.
Hier das Script:
Code:
set Date_folder to {((characters -1 thru -2 of ((100 + (day of (current date)) as integer) as string)) as string) & ".", ¬
    ((characters -1 thru -2 of ((100 + (month of (current date)) as integer) as string)) as string) & ".", ¬
    (characters -1 thru -2 of ((year of (current date)) as string)) as string, ""} as string

set main_folder to (path to home folder as string) & ("Websites:Eusers:e-users.de")

try
    tell application "Finder"
        set under_folder to make folder at main_folder with properties {name:Date_folder}
    end tell
end try
set Y to (path to home folder as string) ¬
    & "Websites:Eusers:e-users.de:" & Date_folder


try
    do shell script "mkdir /Volumes/eusers"
end try
do shell script "mount -t ftp [URL]ftp://USER:[email protected][/URL] /Volumes/eusers/"
set Ordner_Server to "[URL="ftp://Volumes:[email protected]"]Volumes:[email protected][/URL]"
delay 2
list disks


tell application "Finder"
    duplicate disk "[URL="ftp://[email protected]"][email protected][/URL]" to under_folder
end tell

-- Wenn ich das mit Duplicate mache, meint er "under_folder" ist nicht definiert"

set folderlist to (list folder items of Ordner_Server as list)

repeat with X in folderlist
    if X does not start with "." then
        tell application "Finder"
            try
                move document file (Ordner_Server & X as alias) to folder (under_folder as alias)
            end try
        end tell
    end if
end repeat

do shell script "umount /Volumes/[URL="ftp://[email protected]"][email protected][/URL]"
So und in der Version geht es, aber es ist nicht der Ort, wo es hin soll... es soll in:/Users/JaGaller/Sites/Eusers/Backup (ich weiß der Pfad ist anders als oben;))

Code:
tell application "Finder"
    set Date_folder to {((characters -1 thru -2 of ((100 + (day of (current date)) as integer) as string)) as string) & ".", ((characters -1 thru -2 of ((100 + (month of (current date)) as integer) as string)) as string) & ".", (characters -1 thru -2 of ((year of (current date)) as string)) as string, ""} as string
    set sites_folder to (path to sites folder) & ("Eusers:Backup")
    set backupFolder to Date_folder
    set backupPath to make folder of (path to sites folder) with properties {name:backupFolder}
    
    do shell script "mkdir /Volumes/eusers"
    do shell script "mount -t ftp [URL]ftp://eusers:[email protected][/URL] /Volumes/eusers"
    
    delay 2
    
    duplicate disk "[EMAIL="[email protected]"][email protected][/EMAIL]" to backupPath
    
end tell

do shell script "umount /Volumes/eusers"
Und ja, ich habe Onkel G. befragt und die Pfade sind alle richtig!

Wie bekomme ich das zum Laufen?

Liebe Grüße,
Jan!

Eidt: Es geht:
Code:
set commenScript to load script alias ¬
    ((path to library folder from user domain as string) ¬
        & "Scripts folder:Logger.scpt")
tell application "Finder"
    try
        set Date_folder to {((characters -1 thru -2 of ((100 + (day of (current date)) as integer) as string)) as string) & ".", ((characters -1 thru -2 of ((100 + (month of (current date)) as integer) as string)) as string) & ".", (characters -1 thru -2 of ((year of (current date)) as string)) as string, "-1"} as string
        
        set Backup_folder to ((path to desktop as string) & ("Backup"))
        set backupFolder to Date_folder
        set backupPath to make folder at Backup_folder with properties {name:backupFolder}
        
        do shell script "mkdir /Volumes/eusers"
        do shell script "mount -t ftp [URL="ftp://eusers:[email protected]"]ftp://eusers:[email protected][/URL] /Volumes/eusers"
        
        delay 2
        
        duplicate disk "[EMAIL="[email protected]"][email protected][/EMAIL]" to backupPath
        log_event("Backup erfolgreich durchgeführt") of commenScript
    on error
        log_event("Backup fehlgeschlagen!") of commenScript
    end try
end tell

do shell script "umount /Volumes/eusers"
Jetzt würde ich nur noch gerne ein Script schreiben, in dem ich von einem Backup den Server wiederherstelle... Problem ist da nur der Finder...

Bis jetzt sieht es so aus:
Code:
-- Wiederherstellen von einem Backup auf FTP Server
choose folder with prompt "Ordner auswählen, von dem wiederhergestellt werden soll"
set Backup_folder to (result as string)
set server_main to ("[URL="ftp://eusers:[email protected]/"]ftp://eusers:[email protected]/[/URL]" as string)
-- FTP Verbindung herstellen
tell application "Cyberduck"
    connect to server_main
    -- Jede Datei löschen
    repeat with i from 1 to number of items in server_main
        set file_item to item i of server_main
        delete file_item
    end repeat
    delay 5
    -- Ordner uploaden
    (upload Backup_folder to server_main) display dialog
end tell
Fehler:
Code:
„every item of "[URL]ftp://eusers:[email protected]/[/URL]"“ kann nicht gelesen werden.
Mal gucken ob es geht...
 
Zuletzt bearbeitet von einem Moderator:

Mitglied 26876

Gast
So habe was gefunden:
Code:
set Pizza to ((path to desktop) & ¬
	("Backup:07.08.09-1:[email protected]") as alias)
set theServer to "eusers.eu.funpic.de"
set theUser to "eusers"
set theProtocol to "ftp"
set theUploadFolder to "ftp.eusers.eu.funpic.de"
set added_items to Pizza
set the item_count to the number of items in the added_items
if the item_count is greater than 0 then
	with timeout of 300 seconds
		tell application "Cyberduck"
			set theBrowser to (make new browser)
			tell (theBrowser)
				set encoding to "UTF-8"
				connect to theServer with protocol theProtocol as user theUser with initial folder theUploadFolder
				repeat with theFile in added_items
					upload item theFile
				end repeat
				disconnect
			end tell
		end tell
	end timeout
end if

Aber es geht leider nicht:
 

Anhänge

  • Bild 7.png
    Bild 7.png
    39,5 KB · Aufrufe: 96