Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use a perl script to execute another perl script 2

Status
Not open for further replies.

Tript99

Programmer
Dec 4, 2001
13
US
Hello,
I was wondering if it is possible to have a perl script that will open up another existing perl script and execute it. What I'm trying to do is have an EXE that will open up and execute a perl script that is located on a network drive. This way if I ever have to make changes to the perl script I won't have to send the user a new EXE.

Thanks!
Tript.
 
Hi Tript,

Have a look at the system() function in the documenation - perlfunc document.

Mike

"Deliver me from the bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Thanks Mike,
This helps alot. The perlfunc doc is very helpful, I never knew about it before. I got it to access the file but it just opens it up and does not execute it. I'll have to work on that. Thanks for pointing me in the right direction.

Tript.
 
Tript,
A couple of different ways that I use to make system calls are by surrounding the command in backticks or by using the perl command qx().
A nice feature of both of these methods is that you can see the results of the system command.
In your case, there may be a problem with the path to the perl script you are trying to call, or a problem in the perl script itself - it's hard to tell. But if you use backticks or qx() then you can get find out more about why it is not working.
For example:
Code:
print `pwd`; #note - these are backticks (next to the 1 key)
  #or
@dir = `ls -l`;
print @dir;
  #or
print qx(pwd);
  #or
$dir = qx(pwd);
print $dir;
You may not need the output from the command in your final version, but for testing it sure helps to collect any output from the command (in your case, another perl script) to see if it is doing what you want it to do.

Hope this helps!

Brian
 
is perl installed on the machine that's executing the exe? Keep in mind that the system call is to perl.exe, so:
system("perl.exe script.pl")
If perl is on the server, you should be able to run it from there if you include the full path. If you're using any modules, you'll probably have issues too. see: use lib
 
Thanks chazoid!
That worked perfectly!
I appreciate everyone's help.
Tript.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top