Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

executing script one at the time

by Anonymous Monk
on Feb 16, 2004 at 21:27 UTC ( #329448=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks , I need your help in this problem : I have a file which contains scripts that need to be excuted one at the time ,, somthing like this :
-- @@FILES_TO_RUN /dir/scripts/ /dir/scripts/ /dir/scripts/ /dir/scripts/
I need to open that file and run each script at the time : I tried somthing like
while (<FILES_TO_RUN>) { chomp; system(qq($_)); }
but not working . thanks

Replies are listed 'Best First'.
Re: executing script one at the time
by tilly (Archbishop) on Feb 16, 2004 at 21:43 UTC
    Read perlstyle and make sure that your system calls (as it suggests) have informative error messages that tell you what it tried to do and what went wrong.

    It is very likely that $! says something informative about your problem. It is unlikely that any of us will correctly guess what that is.

Re: executing script one at the time
by Vautrin (Hermit) on Feb 16, 2004 at 21:49 UTC

    Try the following code to see if you get any errors:

    use strict; use warnings; while (my $line = <FILES_TO_RUN>) { chomp $line; die ("File does not exist") unless (-e $line); die ("File cannot be executed") unless (-x $line); system(qq($line)); }

    And remember to always have use strict; use warnings; at the top of your scripts.

    Want to support the EFF and FSF by buying cool stuff? Click here.
Re: executing script one at the time
by CountZero (Bishop) on Feb 16, 2004 at 21:36 UTC
    <guessing mode=on>

    As I don't know the OS this is running on, it could be a problem with file permissions or the paths can be all wrong or the OS doesn't know how to run a *.pl file or ...

    <guessing mode=off>


    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: executing script one at the time
by ChrisR (Hermit) on Feb 16, 2004 at 21:34 UTC
    The system command executes and waits for the finish so it can return the result code to you. The exec command executes and never returns. You could use fork if you must have them run at the same.
Re: executing script one at the time
by makar (Novice) on Feb 17, 2004 at 04:57 UTC
    How do you mean not working? Is an error returned? If so, which error? Or do you mean that it runs but does not do what you expected it to? If so, what does it do and what did you want it to do? ~Adam

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://329448]
Approved by b10m
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2022-06-27 08:29 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (88 votes). Check out past polls.