Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: How to run bash file from perl

by ciderpunx (Vicar)
on May 17, 2011 at 15:39 UTC ( [id://905304]=note: print w/replies, xml ) Need Help??


in reply to How to run bash file from perl

Just to add another couple of options to anonymized user 468275's post. You can do this, if you don't care about the output from learn.sh:
@args = ("learn.sh", "arg1", "arg2"); system(@args) == 0 or die "system @args failed: $?"
Whereas this does much the same as using backticks (``)
my $output = qx/learn.sh arg1 arg2/


Replies are listed 'Best First'.
Re^2: How to run bash file from perl
by bndgyawali (Initiate) on May 17, 2011 at 19:08 UTC
    my $afile='dir1/firstfile.txt'; my $bfile='dir2/secondfile.txt'; my $bash_command='learn.sh '.$afile.' '.$bfile.' |'; open(my $output,$bash_command) or die $!; while(my $line=<$output>){ print "$line"; }
    my $afile='dir1/firstfile.txt'; my $bfile='dir2/secondfile.txt'; @args = ("learn.sh", $afile, $bfile); system(@args) == 0 or die "system @args failed: $?"
    my $output=`learn.sh $afile $bfile`;
    I tried three different ways as you all have suggested, but I couldn't make my script work. Please help me what is wrong in it

    Binod

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2025-12-12 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (92 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.