Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Call perl script and capture values in bash.

by MacScissor (Acolyte)
on Sep 18, 2012 at 08:04 UTC ( #994231=note: print w/ replies, xml ) Need Help??


in reply to Re: Call perl script and capture values in bash.
in thread Call perl script and capture values in bash.

Thank you for your fast reply! The perl script generates yesterdays date, saves it in $day $month and $year and prints these 3 variables. I can use this date as one string, that is no problem. But the perl script also has the variable $counter which is also printed. The final output looks like this:

print "Backup date: $day\.$month\.$year\n"; print "$counter files have been successfully saved.\n";
I need to use the date and the $counter value in bash.


Comment on Re^2: Call perl script and capture values in bash.
Download Code
Re^3: Call perl script and capture values in bash.
by prashantktyagi (Scribe) on Sep 18, 2012 at 08:10 UTC
    Parse output like ...
    print "counter=$counter files have been successfully saved.\n";
    In bash capture value assign after "counter=" string..
Re^3: Call perl script and capture values in bash.
by choroba (Abbot) on Sep 18, 2012 at 08:13 UTC
    You can save the output to a bash array to easily access the values:
    out=($(script.pl)) date=${out[2]} counter=${out[3]}
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Thank you both, finally it works! :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-10-25 09:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (142 votes), past polls