Re: Very Simple script driving me nuts!
joe_at_invalid.address
Date: 05/15/04
- Next message: Trent Curry: "Re: Very Simple script driving me nuts!"
- Previous message: Dan Mercer: "Re: Deleting files and folders older than X-days"
- In reply to: Trent Curry: "Very Simple script driving me nuts!"
- Next in thread: Trent Curry: "Re: Very Simple script driving me nuts!"
- Reply: Trent Curry: "Re: Very Simple script driving me nuts!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 15 May 2004 19:14:00 GMT
"Trent Curry" <trentcurry@REM0VEhotmail.com> writes:
> I know I am missing something really trivial here. I've bene away
> from shell scripting over the years, for the most part been working
> with the likes of Perl, C++, and Java, and I seem to have forgotten
> some aspect of shell programming it seems thats biting me in the
> arse, when I wanted to write an utterly simple script to save me
> some time.
>
> sendcmd:
> 1 #!/bin/sh
> 2
> 3 CMD="./sendcommand blah 127.0.0.1 2701 '$*'"
> 4 echo -n "CMD: $*"
> 5 echo
> 6 $CMD
> 7 echo
>
> Say I run it like this, the echo looks fine
>
> $ ./sendcmd do this
> CMD: do this
>
> but sendcommand ask as if no params were passed. If I remove the ''
> around $* on line 3, then it works, but I need literal single quotes
> aroudn the params being pased, so to allow spaces. I wanted to use
> $* so I don't have type any surrounding quotes when I use my script,
> and have the script put singles around that. (Notice I didnt put any
> '' around "do this" on the command line.
Are you sure it's not sendcommand that's messing up? The script you
show works (more or less) as you seem to want it to with all shells
I've tried. For test purposes I changed it to
#!/bin/sh
CMD="echo blah 127.0.0.1 2701 '$*'"
echo -n "CMD: $*"
echo
$CMD
echo
Output:
CMD: do this
blah 127.0.0.1 2701 'do this'
With the sh on Solaris (which is a Bourne shell) echo -n doesn't work
as you want. You're probably better off using printf(1) if you have
it.
Joe
-- "Surprise me" - Yogi Berra when asked where he wanted to be buried.
- Next message: Trent Curry: "Re: Very Simple script driving me nuts!"
- Previous message: Dan Mercer: "Re: Deleting files and folders older than X-days"
- In reply to: Trent Curry: "Very Simple script driving me nuts!"
- Next in thread: Trent Curry: "Re: Very Simple script driving me nuts!"
- Reply: Trent Curry: "Re: Very Simple script driving me nuts!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|