This depends on whether the bash script is being executed by script1.pl, or by some other parent process which runs script1.pl, waits for it to complete, then runs the bash script. In the first case, simply pass the value in the command line like I did in my example, and then do the same from within your bash script. In the latter case, script1.pl would need to return the value to its parent process, which would then pass the value to the bash script.

I think it's very likely that the best solution would be to redo the whole thing as a single Perl script. However, if you already have two Perl scripts and you're just hoping to pass a value from one to the next without making any other changes, use my example, except stick chdir "directory"; at the beginning of script2.pl. That will eliminate the need for a bash script sitting between the two.

Aaron B.
Available for small or large Perl jobs; see my home node.


In reply to Re^5: Use a Variable in a Separate Perl Script by aaron_baugher
in thread Use a Variable in a Separate Perl Script by NinjaOne

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.