Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Running Shell Command

by Anonymous Monk
on Sep 29, 2005 at 20:33 UTC ( #496232=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How I can run the shell command via CGI script? When I do via backticks, it gives error. I have no problem running command on command line. Is there more elegant way to do it?

Replies are listed 'Best First'.
Re: Running Shell Command
by talexb (Canon) on Sep 30, 2005 at 02:00 UTC

    So, to paraphrase what Fletch so ably said, picture this: you've sent your spouse off to get something at Home Depot; you're at home painting. The phone rings .. it's your spouse, and they need directions.

      Hi, I'm calling from the highway, how do I get to Home Depot?

    You, of course, are puzzled .. you turn left at the end of your street, follow the road as it curves past the convenience store/gas station, go over the Leaside bridge and turn right just past the DEL building.

    You don't even know what highway your spouse is on, or what direction they're headed in. How can you possibly give them directions with so little information to go on?

    So that's the bind that I see some people in when they post questions .. they know what they want to do (that's an improvement over some people, believe me), but they're getting 'an error'. Well, the error could be one of a dozen things, each of which has its own solution.

    We're also handicapped because we can't see what's on your screen -- we're relying on you to do that for us, just like you need your spouse to tell you what highway they're on, what direction they're going, what signs they're going past, and what store they think they're going to.

    We may be bright, and quite good at Perl, but we're not all-seeing. Tell us what you've tried, what worked and what didn't work -- and why you think it didn't work. If there are error messages, list them all -- often, you just have to know what the error messages mean, rather than what they're saying.

      Honey, are you there? I'm just pulling your leg -- I'm in the parking lot at the Home Depot, got here no problem. They've got a special on chain saws, want me to pick you up one?

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

    Update: Correct two typos.

Re: Running Shell Command
by Fletch (Chancellor) on Sep 29, 2005 at 20:37 UTC

    Well, looking at the error message you're getting . . . erm.

    So anyhow, looking at the code that's giving you problems . . .

    Well . . . erm . . . it must be sunspot activity. Yeah, that's the ticket.

Re: Running Shell Command
by philcrow (Priest) on Sep 29, 2005 at 20:46 UTC
    This is usually an issue with permissions. The web server does not have the permissions you have when you run it at the command line. The script needs to be executable by the user the server runs as.

    Phil

Re: Running Shell Command
by graff (Chancellor) on Sep 29, 2005 at 21:20 UTC
    In addition to what philcrow said, the program being run in the shell command needs to be findable and readable by the web-server user account. Have you tried using the absolute path to the command, rather than just the command name?

    As Fletch points out, you really should show us the relevant details. Common mistakes like the one(s) you are making are easy enough to guess at, but really pointing out the right way to do something is just about impossible without having some details.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://496232]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2020-05-25 17:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (146 votes). Check out past polls.

    Notices?