- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ksh and quotes
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
Forums
Discussions
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
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
07-31-2002 09:28 AM
07-31-2002 09:28 AM
ksh and quotes
The problem I have is passing the quotes.
Here is the command line abc -s 'a b c'
here is abc:
sas $*
What get run is sas -s a b c
AFter I post I will try to look at past items but I know someone with real knowledge will point me to the solution faster than I can find it.
TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 09:34 AM
07-31-2002 09:34 AM
Re: ksh and quotes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 09:44 AM
07-31-2002 09:44 AM
Re: ksh and quotes
A character can be quoted (i.e., made to stand for itself) by
preceding it with a \. The pair \new-line is ignored. All characters
enclosed between a pair of single quote marks (''), except a single
quote, are quoted. Inside double quote marks (""), parameter and
command substitution occurs and \ quotes the characters \, `, ", and
$. "$*" is equivalent to "$1 $2 ...", whereas "$@" is equivalent to
"$1""$2" ....
Would that help? Sometimes $* is better, sometimes $@
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 09:45 AM
07-31-2002 09:45 AM
Re: ksh and quotes
Still NG.
I even tries abc '''a b c'''
and that does not work.
Any ksh option that says to pass the whole parameter string as one parameter and do not touch the quotes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 09:46 AM
07-31-2002 09:46 AM
Re: ksh and quotes
I am not sure I have understand this correct but perhaps this work for you:
abc -s \`1 2 3\`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 09:57 AM
07-31-2002 09:57 AM
Re: ksh and quotes
echo :$1:
you would see-
:a b c:
This is because those three letters make up parameter #1. If you wish to quote them again to sas, then use-
sas -s "$@"
This will again pass the three letters as one argument to the shell.
Hope this helps...
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 10:06 AM
07-31-2002 10:06 AM
Re: ksh and quotes
Is there any way to tell if the parameters or command line has the quotes in it so I can use $@ in one case and $* in the other?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 10:09 AM
07-31-2002 10:09 AM
Re: ksh and quotes
This worked for the quoted string but then I tried it where there was no quoted string to pass and then the normal command did not work.
Thats what promted the oither reply.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 10:09 AM
07-31-2002 10:09 AM
Re: ksh and quotes
TEST=\'$*\'
sas $TEST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 10:14 AM
07-31-2002 10:14 AM
Re: ksh and quotes
If sas is expecting to see the single quotes, then Ian's example is ok.
If sas is not expecting to see the single quotes, ie the three letters are just the first argument, then you will have to do the following-
eval sas $TEST
But I think this is becoming overkill. Maybe a little more info on what you really are trying to do.
my 2 cents...
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 10:18 AM
07-31-2002 10:18 AM
Re: ksh and quotes
abc script
#!/bin/sh
set -x
args=''
num_args=$#
i=1
while [ $i -le $num_args ]
do
arg=`eval echo \\$"$i"`
if $(echo $arg | grep -q ' ');then
args=$args"'$arg' "
else
args=$args"$arg "
fi
i=`expr $i + 1`
done
echo $args
--end of script--
--test run--
# ./abc -s 'a b c'
+ args=
+ num_args=2
+ i=1
+ [ 1 -le 2 ]
+ + eval echo $1
+ echo -s
arg=-s
+ echo -s
+ grep -q
+ args=-s
+ + expr 1 + 1
i=2
+ [ 2 -le 2 ]
+ + eval echo $2
+ echo a b c
arg=a b c
+ grep -q
+ echo a b c
+ args=-s 'a b c'
+ + expr 2 + 1
i=3
+ [ 3 -le 2 ]
+ echo -s 'a b c'
-s 'a b c'
---end of test---
Rich
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 10:38 AM
07-31-2002 10:38 AM
Re: ksh and quotes
here is what I got from the script:
[ 5 -le 4 ]
+ /cts/sas612/sas -work /prd/works2 -autoexec /prd/preclinical/pbsyst/ahtest/ahtest.sas -initcmd 'af c=ahtest.ahtest.menu.program'
ERROR: Cannot find batch input file '/prd/home/estewar1/c=ahtest.ahtest.menu.program''.
I just do not see where or why there are 2 quotes
Used your script. It seems to do what I want.
Any other ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2002 11:16 AM
07-31-2002 11:16 AM
Re: ksh and quotes
Sometimes simple eludes us.
In this particular case the parameter that I had to pass (stumbled on it) could be separated by spaces or commas.
I just added the comma between the af and the file name and it does not matter about the quotes.
I will try to award points Friday.
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2002 04:05 AM
08-02-2002 04:05 AM