Manual entry into Command Line works, but script won't work

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
montanan
Junior Coder
Posts: 49
Joined: Mon Jul 09, 2007 3:44 pm
Location: San Jose, CA

Manual entry into Command Line works, but script won't work

Post by montanan » Wed Oct 06, 2010 7:42 am

This is very strange. Manual entry into Command Line works, but every variation I can come up with of a Macro Scheduler script that does the same thing won't work.

When I type the following into the command line...

C:\>postie -host:mail.server.net -user:myuser -pass:78abc -msg:1 -file:c:\mailmonitor\msg1.txt -extract

... it works fine and returns...

C:\>postie -host:mail.server.net -user:myuser -pass:78abc -msg:1 -file:c:\mailmonitor\msg1.txt -extract
There are 11 messages waiting (146661 bytes)
1. Fwd: Monday morning meeting
Date: Sun, 3 Oct 2010 20:40:28 -0700
From: [email protected]
To: [email protected]


However, when I use Macro Scheduler to open a command line, enter the same command, and hit enter, I get an error...

C:\Windows\system32>cd \

C:\>postie -host:mail.server.net -user:myuser -pass:78abc -msg:1 -file:c:\mailmonitor\msg1.txt -extract
'postie' is not recognized as an internal or external command,
operable program or batch file.

C:\>


I have tried using RunProgram>cmd /c (and a lot of other things) but I must be doing something wrong. I have looked at the help for the RunProgram command, but do not see why this won't work. Please help!!!


The code I am using is...

Code: Select all


Let>MyCommandPath=\
Let>MyCommand=postie -host:mail.server.net -user:myuser -pass:78abc -msg:1 -file:c:\mailmonitor\msg1.txt -extract
RunProgram>cmd.exe
Wait>1
Send>cd %MyCommandPath%
Press Enter
Wait>1
Send>%MyCommand%
Press Enter

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Wed Oct 06, 2010 7:55 am

The "path" where cmd looks for programs is set differently for you vs. Macro Scheduler.

The best solution is to always fully path executables.

i.e.

Where does 'postie' live? If it's something like
c:\program files\postie\bin

Then execute it like so:

Run>"c:\program files\postie\bin\postie" -host:mail.server.net -user:myuser -pass:78abc -msg:1 -file:c:\mailmonitor\msg1.txt -extract

montanan
Junior Coder
Posts: 49
Joined: Mon Jul 09, 2007 3:44 pm
Location: San Jose, CA

Post by montanan » Wed Oct 06, 2010 2:16 pm

Thank you for your suggestion. Postie.exe resides at C:\Windows\System32\postie.exe, so I changed the command to...

Let>MyCommandPath=\
Let>MyCommand="C:\Windows\System32\postie.exe" -host:mail.server.net -user:myuser -pass:78abc -msg:1 -file:c:\mailmonitor\msg1.txt -extract
RunProgram>cmd.exe
Wait>1
Send>cd %MyCommandPath%
Press Enter
Wait>1
Send>%MyCommand%
Press Enter

... and it still didn't work. I tried the path in lower case as well (but hte above is the literal path).

Could it be something related to Vista?

Maybe I should try to have Macro Scheduler run a .bat file instead.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Oct 06, 2010 2:35 pm

Are you running 64 bit and is postie a 64 bit process? If so see:

http://www.mjtnet.com/blog/2010/09/15/a ... direction/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Wed Oct 06, 2010 2:43 pm

... and it still didn't work.
What was the error?

Another issue is sending keystrokes to a CMD window is troublesome and not recommended. Just use the RUN> command. Since you are running an EXE and not doing file redirection, the CMD shell is not needed. If you need to see the results of what is written to the console window, then you can use redirection to put the output into a file instead. In this case just execute CMD as part of the run> command like so:


Run>cmd /c "C:\Windows\System32\postie.exe" -host:mail.server.net -user:myuser >c:\postie_out.txt

montanan
Junior Coder
Posts: 49
Joined: Mon Jul 09, 2007 3:44 pm
Location: San Jose, CA

Post by montanan » Wed Oct 06, 2010 2:49 pm

Marcus nailed the issue.

I am running 64-bit Vista and that redirection was the issue.

What a relief!

I would recommend that some sort of note be placed in the command help for RunProgram that points 64-bit OS users to the article Marcus referenced.

http://www.mjtnet.com/blog/2010/09/15/a ... direction/

Many thanks for this assistance!

-Richard

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts