The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with script not able to take parameters passed to it dsravan Shell Programming and Scripting 3 02-28-2008 05:09 PM
How to get files names passed to a script unishiva Shell Programming and Scripting 5 11-08-2007 04:01 AM
checking parameter values passed to script ammu UNIX for Dummies Questions & Answers 2 10-05-2007 01:35 PM
Extracting passed in parameters spookyrtd99 Shell Programming and Scripting 2 05-22-2007 11:07 PM
Assigning a Variable all the Parameters passed samit_9999 UNIX for Dummies Questions & Answers 2 12-04-2006 05:21 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-09-2007
dsravan dsravan is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 188
Problem with script not able to take parameters passed to it

Quote:
#!/usr/bin/ksh
$dev_PROFILE_DIR/dev_profile

g_JOB_SCRIPT_1=dev_pre_session.sh
g_JOB_SCRIPT_2=dev_generate_btch_id.sh
g_JOB_SCRIPT_3=dev_generate_dev_load_id.sh

g_PROGRAM_NM=`basename $0`
g_PROGRAM_NM=`echo $g_PROGRAM_NM | sed 's/\.sh$//'`

#number of parameters passed to the script
echo Number of parameters passed : $#

if [ $# > 0 ]
then
g_JOB_NAME=$1
else
echo "Error: in dev_pre_session_task- Missing <JOB_NAME> $# Parameter..."
exit 1
fi

if [ $# > 1 ]
then
g_JOB_TYPE=$2
else
echo "Error: in dev_pre_session_task - Missing <JOB_TYPE> Parameter..."
exit 1
fi

echo parameters are $g_JOB_NAME, $g_JOB_TYPE

echo Starting pre session task for Job: $g_JOB_NAME

$SCRIPT_DIR/$g_JOB_SCRIPT_1 $g_JOB_NAME $g_JOB_TYPE
when I pass any 2 parameters it always says:

Number of parameters passed: 1
and the job_name as x

Can some body help?
  #2 (permalink)  
Old 10-09-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Try using

[ $# -gt 1 ]

the ">" redirects stdout
  #3 (permalink)  
Old 10-09-2007
dsravan dsravan is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 188
Thanks. I will try that and let you know. But how come it's taking it as X then.
  #4 (permalink)  
Old 10-09-2007
dsravan dsravan is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 188
Still the same

Unfortunately, its still taking the paramter as x instead of the paramters being passed. Any suggestion?
  #5 (permalink)  
Old 10-09-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Try debugging by changing the first line to

Code:
#!/usr/bin/ksh -x
  #6 (permalink)  
Old 10-09-2007
dsravan dsravan is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 188
Sorry Guys. It fixed the problem for me. Thanks.
Closed Thread

Bookmarks

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 On




All times are GMT -4. The time now is 07:06 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-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0