Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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.

Replies are listed 'Best First'.
Re^3: Call perl script and capture values in bash.
by choroba (Chancellor) 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! :)
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..

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994231]
help
Chatterbox?
[perldigious]: Also coincidentally, I'm currently in the middle of a winter storm that has dropped 1 foot of snow and is expected to drop another. I might have to adapt this for customers/vendors who come visit and put it at the beggining of every presentation I give.
[Discipulus]: the photo was removed... Cyrano de Berjerac was not of the same idea..
[stevieb]: perldigious: video near our hq in Montreal. Here in Calgary, it's -28c... we've only got 3" of snow so far, but there are several feet in the mountains already
[perldigious]: Snowshoeing time stevieb? I need to buy a pair so I can walk my German Shepherd properly through the country.

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2016-12-06 16:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (112 votes). Check out past polls.