PERL question

Pretender

Banned
Mar 14, 2000
7,192
0
0
What's the command to run a program, and could you give me an example of how to use it?

Thanks :)
 

GL

Diamond Member
Oct 9, 1999
4,547
0
0
exec() and system() I believe are the two functions.

If I remember correctly, exec runs the program and never returns, whereas system runs the program and does return.

The parameters for both I think are just the name of the command on the console.

-GL
 

Pretender

Banned
Mar 14, 2000
7,192
0
0
alright, if I wanted to run
C:\windows\notepad.exe C:\file.txt
(C:\file.txt being the the argument to open notepad), would this be correct:

system("C:\windows\notepad.exe C:\file.txt");
 

GL

Diamond Member
Oct 9, 1999
4,547
0
0
Yeah, that looks fine. Although, you probably should just go ahead and experiment with it.

-GL
 

GL

Diamond Member
Oct 9, 1999
4,547
0
0
Hmm...well I've heard of some problems spawning processes in Perl on a Win32 platform. What version of Perl are you using? I've had pretty good luck with ActiveState's port.

-GL
 

Pretender

Banned
Mar 14, 2000
7,192
0
0
Aha! The problem was I was supposed to use single quotes rather than double quotes. It took me 12 freaking hours to solve that. Aaargh
 

RedRooster

Diamond Member
Sep 14, 2000
6,596
0
76
I believe a statement closed off with ` (the thing under ~) also works.
ie.
`c:\\windows\notepad.exe`