YpR^ Posted August 11, 2004 Share Posted August 11, 2004 (edited) Was wondering... is it possible to make this in AutoIT or do i need another language to make it... A program which open a screen where u can select any file on u'r computer. After selecting the file it'll be uploaded to a specific FTP server with specific login / pass... Possible or do i need to make it in example Delphi Edited August 11, 2004 by YpR^ Link to comment Share on other sites More sharing options...
this-is-me Posted August 11, 2004 Share Posted August 11, 2004 (edited) func upload($flnm, $url, $dir, $user, $pass) delwait(@ScriptDir & "\upload.txt") $ftfile = FileOpen(@ScriptDir & "\upload.txt", 2) If $ftfile <> - 1 Then FileWriteLine($ftfile, 'open ' & $url) FileWriteLine($ftfile, $user) FileWriteLine($ftfile, $pass) if $dir <> "" Then FileWriteLine($ftfile, 'cd ' & $dir) EndIf FileWriteLine($ftfile, 'binary') FileWriteLine($ftfile, 'put "' & FileGetShortName($flnm) & '"') FileWriteLine($ftfile, 'bye') EndIf FileClose($ftfile) RunWait('ftp -s:"' & FileGetShortName(@ScriptDir & '\upload.txt') & '"', '', @SW_HIDE) FileDelete(@ScriptDir & "\upload.txt") EndFunc Edited August 12, 2004 by this-is-me Who else would I be? Link to comment Share on other sites More sharing options...
YpR^ Posted August 11, 2004 Author Share Posted August 11, 2004 thank you... im pretty new to this .. so .. which "unit's" do i have to change ? ($flnm, $url, $dir, $user, $pass) in first line ? Link to comment Share on other sites More sharing options...
Developers Jos Posted August 11, 2004 Developers Share Posted August 11, 2004     delwait(@ScriptDir & "\upload.txt") <{POST_SNAPBACK}>You are missing the delwait function in your scipt.... SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
YpR^ Posted August 11, 2004 Author Share Posted August 11, 2004 well... dont understand much of this .. but... what do i do if i wan't to send a file to this specification's:FTP: ftp://autoit-is-fun.netUSER: AutoPASS: ItDo i need other specification's to send ?Yes... im getting some error's when trying to run it.. something with the delwait(@ScriptDir & "\upload.txt") Link to comment Share on other sites More sharing options...
xircon Posted August 12, 2004 Share Posted August 12, 2004 Here is my ftp script - watch line wrapping!! ;******************************************************************************************* ;** This Script transfers a file from my Unix box to my PC. It accepts user input ;** of a filename and a directory on the Unix machine and uses this to create ;** a text file called ftp.ftp. This is then used to run the command line ftp ;** program supplied with windows. It is a basically wrapper for Microsoft command line Ftp ;******************************************************************************************* ;** Get Filename and Directory $answer1 = InputBox("File Transfer", "Enter Name of File required : ","excusinv.dbf") $answer2 = InputBox("Default Directory","Enter Default Directory : ","/u/foxbase/data") StringLower($Answer1) ;** Bomb out on nul input if @error <> 0 or $answer1="" then msgbox(0,"Message","Bye bye") exit endif ;** Create ftp parameters file FileOpen ( "ftp.ftp", 2 ) FileWriteline( "ftp.ftp", "username" ) FileWriteline( "ftp.ftp", "password" ) FileWriteline( "ftp.ftp", "cd " & $answer2 ) FileWriteline( "ftp.ftp", "binary" ) FileWriteline( "ftp.ftp", "get " & $answer1 ) FileWriteline( "ftp.ftp", "quit" ) fileclose("ftp.ftp") ;** Run ftp program RunWait(@ComSpec & " /c " & 'ftp -s:ftp.ftp 192.168.1.200', "", @SW_HIDE) exit just change "get " to "send " and it will send a file to the specified directory. Have added a lot of notes to help you understand the script. This was my first ever script, when my samaba server went down it saved my bacon!!! Steve Link to comment Share on other sites More sharing options...
YpR^ Posted August 12, 2004 Author Share Posted August 12, 2004 Here is my ftp script - watch line wrapping!! ;******************************************************************************************* ;** This Script transfers a file from my Unix box to my PC. It accepts user input ;** of a filename and a directory on the Unix machine and uses this to create ;** a text file called ftp.ftp. This is then used to run the command line ftp ;** program supplied with windows. It is a basically wrapper for Microsoft command line Ftp ;******************************************************************************************* ;** Get Filename and Directory $answer1 = InputBox("File Transfer", "Enter Name of File required : ","excusinv.dbf") $answer2 = InputBox("Default Directory","Enter Default Directory : ","/u/foxbase/data") StringLower($Answer1) ;** Bomb out on nul input if @error <> 0 or $answer1="" then  msgbox(0,"Message","Bye bye")  exit  endif ;** Create ftp parameters file FileOpen ( "ftp.ftp", 2 ) FileWriteline( "ftp.ftp", "username" ) FileWriteline( "ftp.ftp", "password" ) FileWriteline( "ftp.ftp", "cd " & $answer2 ) FileWriteline( "ftp.ftp", "binary" ) FileWriteline( "ftp.ftp", "get " & $answer1 ) FileWriteline( "ftp.ftp", "quit" ) fileclose("ftp.ftp") ;** Run ftp program RunWait(@ComSpec & " /c " & 'ftp -s:ftp.ftp 192.168.1.200', "", @SW_HIDE) exit <{POST_SNAPBACK}>Some of it which i dont understand 100 % .... If i would send a file example a txt file on my c: - the ftp-server is ftp://autoit.com - login: auto pass: it .... should it look like this? : ;** Get Filename and Directory $answer1 = InputBox("File Transfer", "Enter Name of File required : ","123.txt or c:/123.txt ?") $answer2 = InputBox("Default Directory","Enter Default Directory : ","/ <--- this for home directory ?") StringLower($Answer1) ;** Bomb out on nul input if @error <> 0 or $answer1="" then msgbox(0,"Message","Bye bye") exit endif ;** Create ftp parameters file FileOpen ( "ftp.ftp", 2 ) FileWriteline( "ftp.ftp", "auto" ) FileWriteline( "ftp.ftp", "it" ) FileWriteline( "ftp.ftp", "cd " & $answer2 ) FileWriteline( "ftp.ftp", "binary" ) FileWriteline( "ftp.ftp", "send <--- " & $answer1 ) FileWriteline( "ftp.ftp", "quit" ) fileclose("ftp.ftp") ;** Run ftp program RunWait(@ComSpec & " /c " & 'ftp -s:ftp.ftp 192.168.1.200', "", @SW_HIDE) <-- don't fully understand this ... am i going to write the ftp-adress here ? exit thank you Link to comment Share on other sites More sharing options...
this-is-me Posted August 12, 2004 Share Posted August 12, 2004 @jdeb, Yes. It is simply a function to check whether or not a file was deleted on the first pass and if not, wait until delete works. I have updated the original post. Who else would I be? Link to comment Share on other sites More sharing options...
YpR^ Posted August 12, 2004 Author Share Posted August 12, 2004 i understand **** of this.... im pretty newbie ... oh well.. //this-is-me .... do i have to decompile the script and cahnge the file to be uploaded every time i want to send a new file ? :S and what value's in ur script do i have to change ? Link to comment Share on other sites More sharing options...
xircon Posted August 13, 2004 Share Posted August 13, 2004 (edited) The important part of the script is:ftp -s:ftp.ftp 192.168.1.200This runs program ftp, feeds a simple parameter file (I called it ftp.ftp) and specifies the IP address of the machine.example of ftp.ftp parameter file(My script mainly generates the following:)userpasswordcd /cd/2remote/machine/directorybinarysend file1.dbfget file2.dbfquitThis is username, password, cd command to change directory on remote - see below, binary changes the file transfer type, send file1.dbf from currently active directory on your pc, get file2.dbf from the directory on remote machine from the directory cd to earlier , then quitThis may helpSyntaxftp [-v] [-d] [-i] [-n] [-g] [-s:FileName] [-a] [-w:WindowSize] [-A] [Host]Parameters-v Suppresses the display of FTP server responses. -d Enables debugging, displaying all commands passed between the FTP client and FTP server. -i Disables interactive prompting during multiple file transfers. -n Suppresses the ability to log on automatically when the initial connection is made. -g Disables file name globbing. Glob permits the use of the asterisk (*) and question mark (?) as wildcard characters in local file and path names. For more information, see Ftp: Glob. -s:FileName Specifies a text file that contains ftp commands. These commands run automatically after ftp starts. This parameter allows no spaces. Use this parameter instead of redirection (<). -a Specifies that any local interface can be used when binding the FTP data connection. -w:WindowSize Specifies the size of the transfer buffer. The default window size is 4096 bytes. -A Logs onto the FTP server as anonymous. Host Specifies the computer name, IP address, or IPv6 address of the FTP server to which to connect. The host name or address, if specified, must be the last parameter on the line. /? Displays help at the command prompt. ExamplesTo log on to the FTP server named ftp.example.microsoft.com, type the following command:ftp ftp.example.microsoft.comTo anonymously log on to the FTP server named ftp.example.microsoft.com, type the following command:ftp -A ftp.example.microsoft.comTo log on to the FTP server named ftp.example.microsoft.com and run the ftp commands contained in a file named Resynch.txt, type the following command:This looks ike the syntax you need:ftp -s:resynch.txt ftp.example.microsoft.comThe above is from the windows xp help files.If you still can't get it to work email me direct on xirconuk at yahoo dot co dot uk with full details and I will have a play!!!Steve Edited August 13, 2004 by xircon Link to comment Share on other sites More sharing options...
YpR^ Posted August 13, 2004 Author Share Posted August 13, 2004 THANK U SO MUCH STEVE ... working now... Link to comment Share on other sites More sharing options...
YpR^ Posted August 13, 2004 Author Share Posted August 13, 2004 is it possible to make: RunWait(@ComSpec & " /c " & 'ftp -s:ftp.ftp "192.168.1.200" <--- this part', "", @SW_HIDE) like FileWriteline( "ftp.ftp", "cd " & $answer2 ) <--- u have a "variable" $answer2 .... can u make the ftp-server address variable too ? ... and make a: $answerx = InputBox("FTP-server", "FTP-serverrequired : ","test.com") Link to comment Share on other sites More sharing options...
pekster Posted August 13, 2004 Share Posted August 13, 2004 (edited) is it possible to make: RunWait(@ComSpec & " /c " & 'ftp -s:ftp.ftp "192.168.1.200"Â <--- this part', "", @SW_HIDE) like FileWriteline( "ftp.ftp", "cd "Â & $answer2 ) <--- u have a "variable" $answer2 .... can u make the ftp-server address variable too ? ... and make a: $answerx = InputBox("FTP-server", "FTP-serverrequired : ","test.com") <{POST_SNAPBACK}>You could store stuff to variables, write the proper FTP commands to a text file, close the file handle, and feed that to the DOS FTP command, sure. Although at that rate, it would probably be eaisier to use a real FTP client, such as FileZilla since it will give you a true user interface. Plus you don't have to worry about the full remote server path, which often times you can't guess. Prompting for it before you connect to the server in your AutoIt code will not allow the user to browser the directory, but will require that they have the entire server directory structure memorized. BB tag fix Edited August 13, 2004 by pekster [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
YpR^ Posted August 18, 2004 Author Share Posted August 18, 2004 (edited) Is it possible to "instead of placing the file in same folder" to make a dialog like the attachment ? ... so u can "pick" the file instead Edited August 18, 2004 by YpR^ Link to comment Share on other sites More sharing options...
xircon Posted August 18, 2004 Share Posted August 18, 2004 Try: $ANSWER=FileOpenDialog( "Please choose a File", "c:\", "All (*.*)") Steve Link to comment Share on other sites More sharing options...
YpR^ Posted August 20, 2004 Author Share Posted August 20, 2004 Where in the code should i paste / overwrite ? Link to comment Share on other sites More sharing options...
YpR^ Posted August 20, 2004 Author Share Posted August 20, 2004 (edited) hmm.... dosen't upload anything.. :/.... Do i really have to but the file to upload in the same folder ? Edited August 20, 2004 by YpR^ Link to comment Share on other sites More sharing options...
pekster Posted August 20, 2004 Share Posted August 20, 2004 hmm.... dosen't upload anything.. :/.... Do i really have to but the file to upload in the same folder ? <{POST_SNAPBACK}>No, but you will need to specify either the full path to the file, or the relative path from your CWD (Current Working Directory.) If you don't know the CWD in a DOS shell, you can type 'cd' and it will tell you. You could also cd to the location where the souce is before you upload it, and that would eliminate the need for paths. The same rule could apply for FTP downloads from the commandline. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
YpR^ Posted August 24, 2004 Author Share Posted August 24, 2004 pekster >> could u give me a "script phrase" ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now