Jump to content

Recommended Posts

Posted

Hello!

I would like to run some DOS commands in AutoIT, but I tried both Run an _RunDos, they are doesn't work, why? What I want is to send a file to my FTP server, the DOS commands and Batch is listed on below, please help to check the script listed on below, thanks!

Run("c:\temp\2FTP.bat")

open ftpserver

username

password

cd folder-in-ftp-server

prompt off

mput c:\temp\*.jpg

bye

_RunDOS("ftp")

_RunDOS("open ftpserver")

_RunDOS("username")

_RunDOS("password")

_RunDOS("cd folder-in-ftp-server")

_RunDOS("prompt off")

_RunDOS("mput c:\temp\*.jpg")

_RunDOS("bye")

Posted (edited)

Hello!

I would like to run some DOS commands in AutoIT, but I tried both Run an _RunDos, they are doesn't work, why? What I want is to send a file to my FTP server, the DOS commands and Batch is listed on below, please help to check the script listed on below, thanks!

Run("c:\temp\2FTP.bat")

open ftpserver

username

password

cd folder-in-ftp-server

prompt off

mput c:\temp\*.jpg

bye

_RunDOS("ftp")

_RunDOS("open ftpserver")

_RunDOS("username")

_RunDOS("password")

_RunDOS("cd folder-in-ftp-server")

_RunDOS("prompt off")

_RunDOS("mput c:\temp\*.jpg")

_RunDOS("bye")

The commandline FTP console has its own shell environment. To pass your script to FTP.exe, do this:

Run(@ComSpec & ' /c ftp /s "c:\temp\2FTP.bat"', @TempDir)

That runs the ftp command, with a "/s" switch that tells it to execute the script file inside the ftp shell.

The _RunDOS() for each command is even sillier because the shell environment is created and destroyed for each one. Like opening a command line, typing one command, closing the command console, then opening a new one for each command.

:)

P.S. Note single quotes enclosing double quotes.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

It's doesn't work, with the Run(@ComSpec & '/c ftp /s"d:\temp\startftp.bat"', @TempDir), any other solutions? Thanks!

Hello!

I would like to run some DOS commands in AutoIT, but I tried both Run an _RunDos, they are doesn't work, why? What I want is to send a file to my FTP server, the DOS commands and Batch is listed on below, please help to check the script listed on below, thanks!

Run("c:\temp\2FTP.bat")

open ftpserver

username

password

cd folder-in-ftp-server

prompt off

mput c:\temp\*.jpg

bye

_RunDOS("ftp")

_RunDOS("open ftpserver")

_RunDOS("username")

_RunDOS("password")

_RunDOS("cd folder-in-ftp-server")

_RunDOS("prompt off")

_RunDOS("mput c:\temp\*.jpg")

_RunDOS("bye")

Posted

It's doesn't work, with the Run(@ComSpec & '/c ftp /s"d:\temp\startftp.bat"', @TempDir), any other solutions? Thanks!

Well, you could have tweaked it a little... I coded that line from memory, if you bring up the help (FTP -h) then you see the script parameter is "-s:<path>", so all it takes to fix it is:

RunWait(@ComSpec & ' /c ftp.exe -s:"C:\Temp\Test\Test2.ftp"', @TempDir)

...which I tested with this for Test2.ftp:

open ftp.microsoft.com
anonymous
nobody@nowhere.com
pwd
ls
close
quit

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

Thanks for your help! It's working now, but how to hide the DOS Shell?

Well, you could have tweaked it a little... I coded that line from memory, if you bring up the help (FTP -h) then you see the script parameter is "-s:<path>", so all it takes to fix it is:

RunWait(@ComSpec & ' /c ftp.exe -s:"C:\Temp\Test\Test2.ftp"', @TempDir)

...which I tested with this for Test2.ftp:

open ftp.microsoft.com
anonymous
nobody@nowhere.com
pwd
ls
close
quit

:)

Posted (edited)

Thanks for your help! It's working now, but how to hide the DOS Shell?

Like this??

RunWait(@ComSpec & ' /c ftp.exe -s:"C:\Temp\Test\Test2.ftp"', @TempDir, @SW_HIDE)
Edited by TzarAlkex

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...