Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

shell program, how to pass parameter into a perl program

Posted on 2011-09-25
7
Medium Priority
?
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 84

Expert Comment

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

Assisted Solution

by:Tintin
Tintin earned 400 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 23

Accepted Solution

by:
Kamaraj Subramanian earned 800 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 800 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Utilizing an array to gracefully append to a list of EmailAddresses
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…
Six Sigma Control Plans

670 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