[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

calling perl varibles in a shell script

Posted on 2009-04-21
4
Medium Priority
?
776 Views
Last Modified: 2013-12-26
Hi

How can we call perl variables in a shell script? Can somebody give an example?

Thanks
0
Comment
Question by:AyooshJ
4 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 150 total points
ID: 24196420
Do you mean access them?  Directly, you can't.
You can have perl access the shell's environment variables, through the %ENV variable.

You could have perl output the value of it's variables, and the shell could read those.  What are you trying to do?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 24199760
More detail is needed.

Here are two examples:

Example 1

#!/usr/bin/perl
$ENV{foo}='bar';
system "/path/to/script.sh";

#!/bin/sh
echo $foo

Example 2

#!/usr/bin/perl
system "/path/to/script.sh bar"

#!/bin/sh
echo "$1"
0
 
LVL 85

Expert Comment

by:ozo
ID: 24200227
by "call" do you mean
name, or say, or invoke, or command, or signal, or predict, or summon, or designate, or need, or postpone,  announce, or ... ?
which perl variables do you want to call?  in what perl program?
is the shell process a parent of the perl process?
is the perl process a parent of the shell process?
Do they run on the same machine?
Do they run at the same time?
Are you writing a perl script that needs to work with an existing shell script?
are you writing a shell script that needs to work with an existing perl scipt?
what would these shell and perl scripts do?
0
 
LVL 11

Expert Comment

by:kblack05
ID: 24214806
#!/bin/sh

echo "This is a basic bash shell script"
echo ""
echo "This is a Perl string within the bash script:"
echo ""
perl -e 'for(1..10) {print "$_\n";}'
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question