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
Help needed - ksh shell scripting subbu Shell Programming and Scripting 5 02-15-2008 12:53 PM
Please help me out:-Its Urgent-C Shell Scripting Prince89 Shell Programming and Scripting 0 02-08-2008 01:35 AM
Urgent help needed for ksh shell setting zing_foru UNIX for Advanced & Expert Users 6 11-04-2007 06:53 PM
Urgent help needed - shell script aarora_98 SUN Solaris 3 01-25-2007 02:26 PM
Help needed - shell scripting garric Shell Programming and Scripting 8 05-23-2006 06:08 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-06-2005
swamymns swamymns is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 25
help needed in shell scripting......urgent

Dear friends,
please help me to solve following problem.

I'm running a frontend application from which i'll be invoking the shell script with arguments as given below

-driver -w -p "ABC XYZ" -S -ds con -dn "abc xyz"
i am getting
$1=-driver
$2=-w
$3=-p
$4="ABC
$5=XYZ"
$6=-S
$7=-ds
$8=con
$9=-dn
$10="abc
$11=xyz"

instead, i am expecting following output,
$1=-driver
$2=-w
$3=-p
$4="ABC XYZ"
$5=-S
$6=-ds
$7=con
$8=-dn
$9="abc xyz"

Please help me to get the correct output as mentioned above.

It's very urgent...........

Regards,
swamymns
  #2 (permalink)  
Old 12-06-2005
dangral dangral is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2002
Posts: 699
You should really use getopts:

Link
  #3 (permalink)  
Old 12-06-2005
linuxpenguin's Avatar
linuxpenguin linuxpenguin is offline Forum Advisor  
Registered User
  
 

Join Date: May 2002
Location: India
Posts: 295
if you can be flexible with the way you pass these arguments you can pass it as follows
-driver -w -p \"ABC XYZ\" -S -ds con -dn \"abc xyz\"
  #4 (permalink)  
Old 12-06-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
What OS/shell are you using? I tested the following code:
Code:
#!/usr/bin/xxx
echo first=$1 second=$2 third=$3
The xxx in the above was tested with ksh, sh and csh on HP-UX and it has worked as you want it to.
Code:
# ./test.sh 1 "2 3" 4
first=1 second=2 3 third=4
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 12:11 AM.


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