Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-28-2008
Registered User
 

Join Date: May 2008
Posts: 41
Call a perl script inside a shell script

Hi all,

I have the following snippet of code..

#!/bin/sh

echo "run perl script............"

#Run the verification script
perl bill_ver

echo " perl script completed....."

echo "rename files......"

#Remove from all file in the directories test, test1, test2, test3
for f in /usr/users/rovolis/test/*.tmp ; do newfile=`echo $f | sed 's/\(.*\)..../\1/'` ; mv $f $newfile ; done
echo "rename completed....."


The perl script returns '0' if it is completed successfully or non-zero if not.
What i would like is to perform the rename only if the perl script is completed successfully. How am i going to check this?

Thank you very much for your help
Sponsored Links
  #2 (permalink)  
Old 11-28-2008
Registered User
 

Join Date: Nov 2008
Posts: 20
Use the $? variable right behind the "perl" command to store the returncode of the perl-process. Store it in another variable and do an if later?
  #3 (permalink)  
Old 12-01-2008
Registered User
 

Join Date: May 2008
Posts: 41
Could you please be more specific?
I tried the above but it doesn't seem to work.

Thank you very much
  #4 (permalink)  
Old 12-01-2008
Registered User
 

Join Date: Feb 2008
Posts: 131
#!/bin/sh

echo "run perl script............"

#Run the verification script
perl bill_ver

ret_val=$?

echo " perl script completed....."

if [ "$ret_val" -eq 0 ]
then

echo "rename files......"

#Remove from all file in the directories test, test1, test2, test3
for f in /usr/users/rovolis/test/*.tmp ; do newfile=`echo $f | sed 's/\(.*\)..../\1/'` ; mv $f $newfile ; done
echo "rename completed....."

fi
Sponsored Links
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
invoking a shell script inside cgi shell script smriti_shridhar Shell Programming and Scripting 2 07-09-2008 02:50 AM
Run the command inside perl script vinay123 Shell Programming and Scripting 1 06-13-2008 11:01 AM
here document to automate perl script that call script hogger84 Shell Programming and Scripting 3 10-22-2007 11:15 AM
How to call a perl script from a shell script anumkoshy Shell Programming and Scripting 2 08-30-2007 05:23 AM
calling a C executable from inside a Perl script mark_nsx Shell Programming and Scripting 3 10-07-2005 06:49 AM



All times are GMT -4. The time now is 02:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0