Technical support and scripting issues
Moderators: JRL, Dorian (MJT support)
-
clickfast
- Pro Scripter
- Posts: 58
- Joined: Wed May 23, 2007 12:04 am
Post
by clickfast » Wed Jul 18, 2007 2:39 am
I need to automate the process of compiling perl scripts into binary executables. I have perl running on XP and can manually compile perl scripts just fine... but i want to automate the process.
I do it manually by;
1) going to start>run and typing cmd.exe (going to command prompt)
2) CD c:\perl\bin (changing to Perl\bin directory)
then typing
3) pp -o compiledfile.exe sourcefile.pl (the perl compiler command)
and it compiles my sourfile.pl into into an executable.
All I want to do is automate those steps in Macroscreduler. Here's what I tried and it didn't work! ;-(
Code: Select all
runprogram>c:\windows\system32\cmd.exe -c:\perl\bin -pp -o compiledscript.exe sourcescript.pl
Anyhelp here is MUCH APPRECIATED!!!!!
-
Me_again
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Post
by Me_again » Wed Jul 18, 2007 3:11 am
Try:
Change Directory>c:\perl\bin
Run Program>cmd /c pp -o compiledfile.exe sourcefile.pl
or maybe you need quotes:
Change Directory>c:\perl\bin
Run Program>cmd /c "pp -o compiledfile.exe sourcefile.pl"
If you want the command window to stay open use /k instead of /c
-
clickfast
- Pro Scripter
- Posts: 58
- Joined: Wed May 23, 2007 12:04 am
Post
by clickfast » Wed Jul 18, 2007 3:50 am
I tried both methods below... and it doesn't work... ;-(...
I will keep tweaking to see what I can come up with...
Thanks!
Me_again wrote:Try:
Change Directory>c:\perl\bin
Run Program>cmd /c pp -o compiledfile.exe sourcefile.pl
or maybe you need quotes:
Change Directory>c:\perl\bin
Run Program>cmd /c "pp -o compiledfile.exe sourcefile.pl"
If you want the command window to stay open use /k instead of /c
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Wed Jul 18, 2007 6:47 am
You need multiple commands within the DOS session. Looks like it needs the directory changed to c:\perl\bin but doing that with ChangeDirectory won't affect where the CMD opens. The CD needs to be inside CMD. So the best solution is to use a bat file. We could create a temporary one on the fly:
WriteLn>%TEMP_DIR%\tmp.bat,r,CD c:\perl\bin
WriteLn>%TEMP_DIR%\tmp.bat,r,pp -o compiledfile.exe sourcefile.pl
Let>RP_WAIT=1
Run>%TEMP_DIR%\tmp.bat
DeleteFile>%TEMP_DIR%\tmp.bat
If the commands/parms never change you could have a pre-written bat file, but writing it on the fly is necessary if any part of it differs from one execution to the next - e.g. sourcefile.pl could be a variable:
WriteLn>%TEMP_DIR%\tmp.bat,r,CD c:\perl\bin
WriteLn>%TEMP_DIR%\tmp.bat,r,pp -o compiledfile.exe %sourcefile%
Let>RP_WAIT=1
Run>%TEMP_DIR%\tmp.bat
DeleteFile>%TEMP_DIR%\tmp.bat
-
Me_again
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Post
by Me_again » Wed Jul 18, 2007 1:25 pm
mtettmar wrote: Looks like it needs the directory changed to c:\perl\bin but doing that with ChangeDirectory won't affect where the CMD opens.
Could you explain that a bit please? I'm pretty sure I have used that method to resolve a similar working dir problem, and I tested it last night before posting. If it doesn't actually change the working directory then the dir shown in the command window is very misleading:

-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Wed Jul 18, 2007 1:27 pm
You're right. I just tried it again and it works. Well, my suggestion may be worth a try in this case anyway, as the OP said that changing directory prior to running CMD didn't work in this case.
-
Me_again
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Post
by Me_again » Wed Jul 18, 2007 1:43 pm
I'm not sure that PP is a regular .exe so maybe this is an Execute File thing?
-
clickfast
- Pro Scripter
- Posts: 58
- Joined: Wed May 23, 2007 12:04 am
Post
by clickfast » Wed Jul 18, 2007 9:57 pm
As usual... little mistake...
Me_again wrote:Try:
Change Directory>c:\perl\bin
Run Program>cmd /c pp -o compiledfile.exe sourcefile.pl
or maybe you need quotes:
Change Directory>c:\perl\bin
Run Program>cmd /c "pp -o compiledfile.exe sourcefile.pl"
If you want the command window to stay open use /k instead of /c
The cmd switch /c is required to be a capital /C... here's the working code
Code: Select all
Change Directory>c:\perl\bin
Run Program>cmd /C pp -o compiledfile.exe sourcefile.pl