![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Plz correct my syntax of shell script | girish.batra | Shell Programming and Scripting | 2 | 06-06-2008 03:36 AM |
| calling a shell script from perl | gurukottur | Shell Programming and Scripting | 3 | 10-05-2006 08:48 AM |
| Box A's perl script calling box B's shell script | new2ss | Shell Programming and Scripting | 1 | 09-13-2006 03:17 AM |
| Calling CGI Perl in Shell script [urgent] | DeepakXavier | Shell Programming and Scripting | 0 | 10-08-2005 10:51 PM |
| Calling privately installed module from script help please | sdiva | UNIX for Dummies Questions & Answers | 2 | 02-09-2002 06:19 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Correct Syntax For Calling Shell Script in Perl Module
Problem: I have a shell script that will be called by a Perl module that will connect to a db and delete rows. The Perl module will be called by CRON. I am using a Perl module to call a shell script because I need to get the db connection from Perl.
Here is the Perl pseudocode: #!/usr/local/bin/perl5.00506 use DBI; ##dblogin.pl provides a connection to the db. I retrieve the id, password, ##and host server variable from dblogin.pl require "/cgi-bin/pswd/dblogin.pl"; $db_connection = $DB_id/$DB_pswd\@$DB_server; #here is where I do not know what to do: Call sh script RemoveRpts.sh and pass variable $db_connection |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
Code:
RemoveRpts.sh $db_connection Code:
#!/bin/ksh
typeset db_connection=""
if [ -n "$1" ] ; then
print - "Error: no database connection passed."
exit 1
else
db_connection="$1"
fi
# ... your code goes here
exit 0
bakunin |
|
#3
|
|||
|
|||
|
If $db_connection is just a string containing the DB name/hostname/username/password etc. then it is easy.
system("/path/to/RemoveRpts.sh '$db_connection'"); If it is a filehandle opened by DBI or so, then you can't pass it as a command-line argument. A filehandle is not a string, and can't be passed on the cmdline. |
|
#4
|
|||
|
|||
|
Thanks to all that have responded
I am going to use system to call my shell script. Thank you for your help.
|
|
#5
|
|||
|
|||
|
Quote:
bakunin |
|||
| Google The UNIX and Linux Forums |