And, yes, there was a copy/paste typo in my code...
david
Main Topics
Browse All TopicsHello,
I have an apache web server (on Ubuntu) that is running perl, and i would like to do the following. I would like an upload file functionality on the site, which once a user has uploaded a file to the webserver, an bash shell application is launched once the file is uploaded and the bash shell responses are displayed in the browser.
So I have the upload functionality upload.cgi, at the end of which I have put a command:
`progname -f /var/www/$filename -t /path to other folder/`;
Is it ok to run the bash command simply using ` `, or do i need to use the system() command?
I am assuming this will run progname in the background using the newly uploaded $filename, as if i had typed it in as bash shell .
I would like to display the responses of the bash shell in the browser.
Is this possible? How would it be done?
I have included the full code of upload.cgi below.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: David_BothamPosted on 2009-10-25 at 08:14:01ID: 25656859
You have options with regard to calling your bash script. A good page to bookmark as a reference is the 'perlipc' man page.
Below, I show an example of using a pipe and the perl builtin 'open'.
Although, you could alternatively use just the back ticks and capture everything in an array, like this:
my @bash_output = `progname -f /var/www/$filename -t /path to other folder/`;
foreach my $line (@bash_output) {
#Process output here...
}
However, if the bash script returns a huge amount of stuff, you might wind up with a huge array.
Using the pipe approach gives you the opportunity to deal with the bash commands output 1 line at a time, and bail out, if you decide that is the thing to do...
David
Select allOpen in new window