CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
system(start $command) in Win32

 



bhardage
New User

Feb 1, 2008, 12:15 PM

Post #1 of 6 (811 views)
system(start $command) in Win32 Can't Post

I'm trying to run a GUI testing program using perl in Cygwin on my Windows XP.

One of the lines in my example code is as follows:


Code
system("start calc.exe");


As I understand it, this is how you start an application and get the Perl script to continue running (I obviously need this functionality to be able to test the application) in a Win32 system, but it's generating an error. I get the 'cannot execute "start": No such file or directory' error.

Any ideas on what I'm doing wrong? If worse comes to worse I'll look for a new module that allows background processes, but I thought I'd be able to do it this way. Could someone correct me please?


KevinR
Veteran


Feb 1, 2008, 12:28 PM

Post #2 of 6 (808 views)
Re: [bhardage] system(start $command) in Win32 [In reply to] Can't Post

You probably don't need ''start, try like this:

system('C:/path/to/calc.exe');

See if that works.

windows fully supports forward slashes in path statements so use them instead of backslashes as much as possible.
-------------------------------------------------


bhardage
New User

Feb 1, 2008, 12:31 PM

Post #3 of 6 (807 views)
Re: [KevinR] system(start $command) in Win32 [In reply to] Can't Post

The problem is not that I can't start the calculator; the problem is that I can't figure out how to continue running my script after the system call while the calculator is still open.

Thanks.


KevinR
Veteran


Feb 1, 2008, 12:48 PM

Post #4 of 6 (805 views)
Re: [bhardage] system(start $command) in Win32 [In reply to] Can't Post

ahh.... I misunderstood. I am not sure how to do what you want. system() forks a new process and waits for the process to end before beginning again. You may have to use Threads, but I have no experience with threads. Then again, there may be a solution I am just not aware of. Ask on www.perlmonks.com if you want to, maybe someone there will know something useful for you. Report back here if you do get a solution, it will be good to know for future reference.
-------------------------------------------------


bhardage
New User

Feb 1, 2008, 1:22 PM

Post #5 of 6 (804 views)
Re: [KevinR] system(start $command) in Win32 [In reply to] Can't Post

Thank you for the perlmonks suggestion.

The 'system("start $command")' does in fact work, but Cygwin doesn't default to using cmd.exe so to accomplish this correctly in Cygwin I have to use 'system("cmd.exe /c start $command")'


KevinR
Veteran


Feb 1, 2008, 1:35 PM

Post #6 of 6 (802 views)
Re: [bhardage] system(start $command) in Win32 [In reply to] Can't Post


In Reply To
Thank you for the perlmonks suggestion.

The 'system("start $command")' does in fact work, but Cygwin doesn't default to using cmd.exe so to accomplish this correctly in Cygwin I have to use 'system("cmd.exe /c start $command")'


Cool, thanks for showing me how to do something new!
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives