Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

(zdog) Re: Find the permission problem

by zdog (Priest)
on Dec 29, 2000 at 22:48 UTC ( #48861=note: print w/ replies, xml ) Need Help??

in reply to Find the permission problem

Try doing @arr=($command,$arg1); system("@arr");. Without the quotes it returns a value of 2 in your case.

Zenon Zabinski | zdog |

Comment on (zdog) Re: Find the permission problem
Download Code
Replies are listed 'Best First'.
(tye)Re: Find the permission problem
by tye (Sage) on Dec 29, 2000 at 22:57 UTC

    Wrong. system() can take a single string or a list of strings (and an optional direct object). If a list of more that one string is given, then Perl won't call a shell to interpret the command-line string (that you didn't give it). If just one string, then Perl will call a shell if the string isn't simple enough (that is, if the string doesn't have any shell meta characters, it will just split it on whitespace and use fork()/exec() just as if you had given it more than one value).

    Of course, platforms that don't have fork() don't quite obey this rule.

            - tye (but my friends call me "Tye")
      tye, perlfunc system() doesn't talk about taking an optional direct object nor am I finding it in any of my books. Where would I go to find more information on this topic?


        In the following, the "PROGRAM" (which isn't followed by a comma) is the optional indirect object:

        system LIST system PROGRAM LIST [...] Like `exec', `system' allows you to lie to a program about its name if you use the `system PROGRAM LIST' syntax. Again, see the exec entry elsewhere in this document.
        at least I think that is what Larry called that.

                - tye (but my friends call me "Tye")
Re: Re: Find the permission problem
by wombat (Curate) on Dec 29, 2000 at 22:53 UTC
    Tried it just now, no effect. $?==9728 $?>>8==38

    tye Giving it a straight string System("/dirstruct/dirstruct2/cgi-bin/subdir/progname static_argument_value"); produced the same effect.

    i0cgi-bin's permissions are "root html rwxrwxr-x" cgi-bin/subdir's are "wombat apache rwxrwxr-x" the program I'm trying to run is "wombat wombat rwxr--r-x" and the target app is "wombat apache rwx--x--x"
      rwx--x--x is a bad set of permissions for a Perl script (assuming that's what it is). Scripts need to be read and interpreted by an interpreter, which means the script needs to be readable to the interpreter. If your script is owned by yourself, but merely executable by the user running the interpreter (apache?), it won't be able to read the script and will fail.

      Try setting the permissions to something more sane, like 755, and see if that helps.

      In addition, if you're frequently executing one Perl script from within others, you may be interested in breaking that Perl script out into a module, and simply 'use' that module from your other Perl scripts that need to get at that common code.

      If you need the variables: you can always do: system("$command $arg");


      my $cmd = "$command $arg"; system($cmd);

      Zenon Zabinski | zdog |

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://48861]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2015-11-30 06:22 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (759 votes), past polls