- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Passing two-word input to shell script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 05:05 AM
04-17-2003 05:05 AM
Passing two-word input to shell script
Thank you for any advice!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 05:12 AM
04-17-2003 05:12 AM
Re: Passing two-word input to shell script
You can use getopt in shell scripts. Check the man page for details.
cheers
Umapathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 05:12 AM
04-17-2003 05:12 AM
Re: Passing two-word input to shell script
get it as two variables :-
$1 and $2
then $1+$2 = $3
then pass the variable $3.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 05:17 AM
04-17-2003 05:17 AM
Re: Passing two-word input to shell script
$* will give you all the arguments.
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 05:17 AM
04-17-2003 05:17 AM
Re: Passing two-word input to shell script
two strings "one string" one\ more\ string
In the above example, there are 4 strings. "one string" and one\ more\ string will each be assigned to a single variable.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 05:18 AM
04-17-2003 05:18 AM
Re: Passing two-word input to shell script
Have a look at the getopt program (see its manpage).
It makes parsing of commandline switches so much easier.
Basically, quoting strings that contain whitespace (e.g. "Process Manager"), or quoting each whitespace (e.g. Process\ Mangare) should deliver the argument as one token.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 05:22 AM
04-17-2003 05:22 AM
Re: Passing two-word input to shell script
if the script is called like this -
$ script.sh -p xxx -user yyy -role "hello world!"
then add this line to your script -
IFS='"' # IFS=internal field separator
works for me.
HTH.
- ramd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2003 05:26 AM
04-17-2003 05:26 AM
Re: Passing two-word input to shell script
- ramd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2003 05:23 AM
04-18-2003 05:23 AM
Re: Passing two-word input to shell script
optionvar1=$1
optionvar2=$2
optionvar3="$3 $4"
This should work as well
it sets a variable = to the command line options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2003 09:41 AM
04-18-2003 09:41 AM
Re: Passing two-word input to shell script
when you make the variable assignment of $1 in your script, is $1 qouted? It should be.
regards,
John K.