LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > CGI/Perl/Python > Results from a system call

Reply
 
Thread Tools Display Modes
  #1  
Old 02-21-2007, 08:37 AM
rjulich rjulich is offline
New Member
 
Join Date: Feb 2007
Posts: 4
Default Results from a system call

Is it possible to put the results from a system call into a variable? I tried:

$variable = system("fgrep date $file");
print "VARIABLE: $variable\n";

The results from the system call print to STDOUT, but when I print $variable, it prints:

VARIABLE: 0

I assume that the system call it returning 0 to mean that the command was successful, but is there a way to put the results from that system call into a variable?

Thank you in advance.
Ray
Reply With Quote
  #2  
Old 02-21-2007, 10:32 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,585
I am not a perl programmer, probably cannot give your the correct answer. You should refer to a Perl programming book.
In shell script I can use:

variable=`fgrep date $file`

to get result from the shell command, not sure about Perl though.
Reply With Quote
  #3  
Old 02-21-2007, 11:00 AM
rjulich rjulich is offline
New Member
 
Join Date: Feb 2007
Posts: 4
That worked. Thank you very much for the help. It's important to remember to use ` instead of '.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:51 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.