Link to home
Create AccountLog in
Avatar of mfarid2
mfarid2

asked on

Strange shell script problem!

I am executing a shell script as follows:

ksh /Fld1/Fld2/MyScript.ksh  /Fld1/Fld2/  WinBox UID PWD!123 /FTPFld1/FTPFLD2 FileToUpload1.txt FileToUpload2.txt

After I execute, I get the following back displayed by the system:
ksh /Fld1/Fld2/MyScript.ksh  /Fld1/Fld2/  WinBox UID PWDvi MyScript.ksh /FTPFld1/FTPFLD2 FileToUpload1.txt FileToUpload2.txt

As a result, the log in fails and I cannot upload the file. As you can see, the "PWD!987" gets replaced with "PWDvi" and the script name reappears as a parameter. Sometimes a different script name reappears as a parameter. This is very strange behavior. Can anybody shed some light?
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
If you are using tcsh
   History substitution
       Each  command,  or  ``event'',  input from the terminal is
       saved in the history list.  The previous command is always
       saved, and the history shell variable can be set to a num-
       ber to save that many commands.  The histdup  shell  vari-
       able  can  be set to not save duplicate events or consecu-
       tive duplicate events.

       Saved  commands  are  numbered  sequentially  from  1  and
       stamped with the time.  It is not usually necessary to use
       event numbers, but the current event number  can  be  made
       part  of  the prompt by placing an `!' in the prompt shell
       variable.

       The shell actually saves history in expanded  and  literal
       (unexpanded) forms.  If the histlit shell variable is set,
       commands that display and store history  use  the  literal
       form.

       The  history  builtin  command can print, store in a file,
       restore and clear the history list at any  time,  and  the
       savehist and histfile shell variables can be can be set to
       store the history list automatically on logout and restore
       it on login.

       History  substitutions  introduce  words  from the history
       list into the input stream, making it easy to repeat  com-
       mands,  repeat arguments of a previous command in the cur-
       rent command, or fix spelling  mistakes  in  the  previous
       command  with  little  typing  and a high degree of confi-
       dence.
in bash
       History  expansion  is  performed immediately after a com-
       plete line is read, before the shell breaks it into words.
       It  takes  place  in two parts.  The first is to determine
       which line from the history list to use  during  substitu-
       tion.   The  second is to select portions of that line for
       inclusion into the current one.  The  line  selected  from
       the  history  is  the event, and the portions of that line
       that are acted upon  are  words.   Various  modifiers  are
       available  to  manipulate the selected words.  The line is
       broken into words in the  same  fashion  as  when  reading
       input,  so that several metacharacter-separated words sur-
       rounded by quotes are considered one word.  History expan-
       sions  are  introduced  by  the  appearance of the history
       expansion character, which is ! by  default.   Only  back-
       slash  (\)  and single quotes can quote the history expan-
       sion character.
Avatar of Tintin
Tintin

What ozo said.

I'm guessing your login shell is bash.
all shells (except plain old sh) have to escape ! with \ as it is a history meta character, even enclosed in single or double quotes

If the UID and PW are for  an FTP file transfer, look into setting them in the '.netrc' file to keep them secret.

http://linux.die.net/man/5/netrc
http://www.scit.wlv.ac.uk/cgi-bin/mansec?4+netrc