![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Newbie Question: passing a variable into java from script? | Cailet | Shell Programming and Scripting | 1 | 10-18-2007 10:31 PM |
| passing variable to my script | aladdin | UNIX for Dummies Questions & Answers | 5 | 06-18-2007 10:34 AM |
| Passing a variable into an awk script | Khoomfire | UNIX for Advanced & Expert Users | 5 | 09-05-2006 09:44 AM |
| passing ip address as a variable to script for ftp | Gerry405 | UNIX for Dummies Questions & Answers | 2 | 09-01-2005 06:26 AM |
| passing awk variable to the shell script | bcheaib | Shell Programming and Scripting | 3 | 07-21-2004 11:00 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
passing asterisk to a script as variable
I'm writing a script that will ssh to a number of hosts and run commands. I'm a bit stumped at the moment as some of the commands that I need to run contain wildcards (i.e. *), and so far I have not figured out how to escape the * character so the script doesn't expand it. More specifically, here's an excerpt of the script.
Quote:
|
|
||||
|
Nope, still doesn't work... I tried that one as well. It doesn't expand the file list anymore, but then I have the backslash as part of my variable (see below for an example). I'm not sure it's the shell that's expanding the variable: Code:
$ echo "some_command \* options" some_command \* options $ echo "some_command * options" some_command * options meanwhile, by adding "echo $COMMAND" to my script, I get: Code:
./test-script "some_command * options" some_command ...list of files... options ./test-script "some_command \* options" some_command \* options I tried running the script from bash and ksh with the same results. |
|
|||||
|
Quote:
Quote:
Quote:
|
|
|||||
|
As previously stated in an ssh script, the commands ( and eventually all the special characters in them, for example: *, $, ...) will be evaluated first by the current shell, before ssh-in.
So you need to properly escape all of them. For more check these threads: How to execute multiple commands via ssh IF condition failing in a SSH script - |
![]() |
| Bookmarks |
| Tags |
| unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|