Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

shell program, how to pass parameter into a perl program

Posted on 2011-09-25
7
Medium Priority
?
366 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 85

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 85

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
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…
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…

916 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