Gossamer Forum
Home : General : Perl Programming :

Execute a command line and get the value...

Quote Reply
Execute a command line and get the value...
Ok, I've been scratching and searching around for this for a while now. Basically, what I need to do is execute a function, and then return its value. The function needs to be run via a command line, i.e with the ``'s. At the moment I have;

`perl filetorun.cgi`;

However, I can't seem to be able to get the results of that page shown in a variable. I tried;

$something = `perl filetorun.cgi`;

But that didnt return anything.

Is there a function or something, like execute(), that will allow me to execute commands, and then get the result of it into a variable?

Thanks in advance

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Execute a command line and get the value... In reply to
You could try,
Code:
open(RESULT, "/usr/bin/perl filetorun.cgi|");
@result = <RESULT>;
close(RESULT);
The lines of your output are then stored in @result, which you can process further.

Hope that helps.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Execute a command line and get the value... In reply to
Interesting. I'll try that. Thanks Smile

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!