Solved

shell program, how to pass parameter into a perl program

Posted on 2011-09-25
7
352 Views
Last Modified: 2012-05-12
#!/bin/bash
user=Dave

#How to call a perl script /tmp/student.pl and pass it the value Dave, and perl script returns 0 or 1
0
Comment
Question by:rgbcof
7 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 36597228
perl /tmp/student.pl $user
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 100 total points
ID: 36597237

#!/bin/bash
user=Dave
/tmp/student.pl $user

Open in new window

0
 

Author Comment

by:rgbcof
ID: 36597242
How do I assign the return value from the perl script?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 23

Accepted Solution

by:
Kamaraj Subramanian earned 200 total points
ID: 36597270
#!/bin/bash  
user=Dave  
retval=$(/tmp/student.pl $user)
echo $retval

Open in new window

0
 

Author Comment

by:rgbcof
ID: 36597296
How do I get my perl program to return a value?

#!/usr/bin/perl
#how to return value from this perl program?
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 200 total points
ID: 36597314
if you
retval=$(/tmp/student.pl $user)
to get the text printed to stdout
then you could use
#!/usr/bin/perl
print 1;

or

#!/usr/bin/perl
print 0;

or

#!/usr/bin/perl
print "0\n";

or

#!/usr/bin/perl
print "1\n";

if you want to use the exit status in a command expression or $?
then you might use

#!/usr/bin/perl
exit 0;

or

#!/usr/bin/perl
exit 1;


0
 

Author Closing Comment

by:rgbcof
ID: 36597334
Print works (like below), however, exit does not work.  I don't really know why?

#!/usr/bin/perl
print 1;
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

810 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