Solved

shell program, how to pass parameter into a perl program

Posted on 2011-09-25
7
347 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…

760 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