josephlo

How to run external program with parameters.

18 posts in this topic

Hi,

I am new to this forum and would appreciate some help to one of the script I am writing.

I wanted to code a rsync script to run automatically.

The rsync command line script (when executed at windows console window) is

c:\program files\deltacopy\rsync.exe -v -rlt -z -avr --chmod=a+rwx,g+rwx,o+rwx /cygdrive/D/#PERSONAL FILE STORAGE/ 192.168.1.3::disk1_Archive1/Vostro//#PERSONAL FILE STORAGE/

and this command works well in a console window.

My autoit script looks like this.

ShellExecute("c:\program files\deltacopy\rsync.exe", "-v -rlt -z -avr --chmod=a+rwx,g+rwx,o+rwx /cygdrive/D/#PERSONAL FILE STORAGE/ 192.168.1.3::disk1_Archive1/Vostro//#PERSONAL FILE")

But the script is not running.

Appreciate if anyone could give me some insights.

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try using Run() function instead of ShellExecute()

There may be an issue with spaces, but try it first.

EDIT:

ie

$sRun = "c:program filesdeltacopyrsync.exe -v -rlt -z -avr --chmod=a+rwx,g+rwx,o+rwx /cygdrive/D/#PERSONAL FILE STORAGE/ 192.168.1.3::disk1_Archive1/Vostro//#PERSONAL FILE STORAGE/"

Run($sRun)

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Thanks John for your reply. There is no error message when compiling/running but the script is still not executing....if it does i will be able to see the server be rsynced with the files from the source folder.

Any ideas?

Thanks again

Share this post


Link to post
Share on other sites

try this version and see if there are any errors:

Run(@ComSpec & " /k c:program filesdeltacopyrsync.exe -v -rlt -z -avr --chmod=a+rwx,g+rwx,o+rwx /cygdrive/D/#PERSONAL FILE STORAGE/ 192.168.1.3::disk1_Archive1/Vostro//#PERSONAL FILE")

Just replace the /K with /C when it works to have the window closed automatically and look at the other options when you want the window not to appear at all.

Jos ;)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi Jos, Thanks for that.

If I use

Run(@ComSpec & " /K c:program filesdeltacopyrsync.exe -v -rlt -z -avr --chmod=a+rwx,g+rwx,o+rwx /cygdrive/D/#PERSONAL FILE STORAGE/ 192.168.1.3::disk1_Archive1/Vostro//#PERSONAL FILE STORAGE/")

The cmd.exe console window will be launched (but it is not doing anything else) and the script will not run.

If I use

Run(@ComSpec & " /C c:program filesdeltacopyrsync.exe -v -rlt -z -avr --chmod=a+rwx,g+rwx,o+rwx /cygdrive/D/#PERSONAL FILE STORAGE/ 192.168.1.3::disk1_Archive1/Vostro//#PERSONAL FILE STORAGE/")

A console window will open and close immediately (in a flick of an eye) and the script is also not executing.

Any other thoughts?

Thanks again

Edited by josephlo

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

What happens when you use the /K as suggested? (Guess the first command was supposed to show /K... right?)

Any errors/messages shown in the CMD window when you use it with /K?

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Sorry. I make a typo in my reply. The first code is with the /K command. I have amended my post above.

The CMD window but there are no error messages whatsoever. The CMD window just open and sit there....not doing anything...

Edited by josephlo

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hi josephlo,

the issue is with long filenames with spaces in this case 'program files'

Run(@ComSpec & " /C 'c:program filesdeltacopyrsync.exe' -v -rlt -z -avr --chmod=a+rwx,g+rwx,o+rwx '/cygdrive/D/#PERSONAL FILE STORAGE/' '192.168.1.3::disk1_Archive1/Vostro//#PERSONAL FILE STORAGE/'",'c:program filesdeltacopy')

Regards

Deltarocked

Edited by deltarocked

Share this post


Link to post
Share on other sites

Couple of questions:

  • Does the command "as-is" work when typed into an CMD window manually?
  • Any specific Workdir required for the command to work?

One thing I would have assumed is that you need to Double quote the paths shown in the commandline like:

Run(@ComSpec & ' /k c:program filesdeltacopyrsync.exe -v -rlt -z -avr --chmod=a+rwx,g+rwx,o+rwx "/cygdrive/D/#PERSONAL FILE STORAGE/" "192.168.1.3::disk1_Archive1/Vostro//#PERSONAL FILE STORAGE/"')

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Yep. The command that I mentioned works well.

This is what I currently have in a CMD script. I copied and pasted exactly from the cmd file.

"c:Program FilesDeltacopyrsync.exe"  -v -rlt -z --delete -avr --chmod=a+rwx,g+rwx,o+rwx "/cygdrive/D/#PERSONAL FILE STORAGE/" "192.168.1.3::disk1_Archive1/08_Joseph_and_Norah//#PERSONAL FILE STORAGE/"

This works well but for whatever reason, it is not working with AutoIT.

Share this post


Link to post
Share on other sites

This should be the AutoIt3 version of your last posted line:

Run(@ComSpec & ' /k "c:Program FilesDeltacopyrsync.exe"  -v -rlt -z --delete -avr --chmod=a+rwx,g+rwx,o+rwx "/cygdrive/D/#PERSONAL FILE STORAGE/" "192.168.1.3::disk1_Archive1/08_Joseph_and_Norah//#PERSONAL FILE STORAGE/"')

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Ok. I tried that and a cmd window pops up and it says

'C:Program' is not recognized as an internal or external command, operable program or batch file.

Share this post


Link to post
Share on other sites

ok ....try this version:

Run(@ComSpec & ' /k ""c:Program FilesDeltacopyrsync.exe"  -v -rlt -z --delete -avr --chmod=a+rwx,g+rwx,o+rwx "/cygdrive/D/#PERSONAL FILE STORAGE/" "192.168.1.3::disk1_Archive1/08_Joseph_and_Norah//#PERSONAL FILE STORAGE/""')

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Jos, u are brillant! That works like a charm!!!

I can see that the ' and " are pretty confusing in this kind of script. Thanks again!!! U rock!

Share this post


Link to post
Share on other sites

I know there is something goofy going on every now and then with Commandline lexing but know that surrounding the whole command with an extra set of doublequotes often solves it.

Enjoy,

Jos ;)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

"c:\program files\deltacopy\rsync.exe",
Why did the inverted slash disappeared from your last posts? The message "Program is not recognized" is the result of the lack of "\" after the c: , and this makes CMD processor search for a program called "program" that is the first free word in the string.

 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

MisterVSE,

Quote

Why did the inverted slash disappeared from your last posts?

One of the forum updates did that to every piece of previously posted code - and very happy we all were, NOT!

M23

Edit: Welcome to the AutoIt forums.

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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