Solved

shell program, how to pass parameter into a perl program

Posted on 2011-09-25
7
348 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
UNiX Script filesystem space usage Part2 54 78
bash_profile contents & MacPorts - Need To Be Changed 4 64
Bash Script-Trigger email when server reboots 11 68
Perl Untar File 1 26
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now