Perl question
Hey all,
I am using perl to open another program and to run the program. The program uses a shell, and I was wondering how to exactly program with it. Right now I have: $prog = "prog"; $status = system($$prog"); #The program opens correctly in a shell, I don't know how to run the shell of the new program #this is what I have tried print $status "open blablablablablabla"; #but it is the correct syntax and all any tips? Thanks in advance eagle |
Are you trying just to execute the program, or to control it and give input to it while it's running? Simply executing the program is almost what you've got there:
$returnValue = `command goes here`; For example, to grep for the phrase "stuff" in a file "textfile.txt", you'd do $returnValue = `grep stuff textfile.txt` just like it was on the commandline. Using system() won't actually get you a meaningful return value, in case you're looking for one. Giving continuous input to a program you're trying to kick off inside of your perl script is quite a bit more complicated. Edit: for clarity's sake, those are backticks (`), not single-quotes ('). |
IIRC Perl allows you to use pipes to interact with other programs. If you want to write to the standard input of a program, you have to create a file handler like this:
Code:
FH = open("| programname","w"); Code:
FH = open("programname |", "r"); HTH! PS: There has been a lot of time since the last time I programed in Perl, so the syntax could be slightly different. |
If that birthday cake near your name means it's your birthday, happy birthday enemorales. :)
|
All times are GMT -5. The time now is 06:11 PM. |