I've never heard of a shell which doesn't take -s. Even weird things like csh do it. But -- might be less common, though it's luckily optional.
Quote:
Originally Posted by doonan_79
I'm running a Korn shell (ksh) and I think the "-s" switch gave me issues.... are those two dashes required? i.e. the "--" after "-s"? Thanks!
If your shell doesn't take them, leave them out, they're optional.
What the double-dashes do is prevent the shell from interpreting arguments after it as flags like -f or what have you, which could change the behavior of the shell.
Unfortunately none of these fixes my issue. Actually the "-s" switch without the "--" worked for me with my direct (no sesu) command. Here is the working command.
However once I spice it up and introduce a sesu command into the mix it fails. This is the failing statement:
so the difference is that it must need a different kind of call for the "-c" command switch for sesu I think.... any ideas?
---------- Post updated at 10:46 ---------- Previous update was at 10:40 ----------
NB have tried that with and without exec in addition to "-c"
---------- Post updated at 11:03 ---------- Previous update was at 10:46 ----------
OK the "-c" on the sesu seems to remove the need to call "exec". However I'm guessing the "-s", which I intend as a switch on the ksh, is actually trying to be interpreted as part of the sesu..... tried using apostrophes as below but still not working... getting the error: "/bin/su: a: No such file or directory"
(NB being in Korn first to run this code) ---------- Post updated at 14:29 ---------- Previous update was at 11:03 ----------
OK almost cracked I think - need apostrophes around the whole passed command - E.g.
however..... I find now that I cannot dynamically generate this command. If I pass that whole command string:
as a variable $command. Then it doesn't work... if I run it without variable substitution it does work... cannot figure out why - the var does include the speech marks and apostrophes - if you echo it, then it comes out exactly as the command that works when you run it all in one line....
The error btw is as follows: ---------- Post updated at 14:57 ---------- Previous update was at 14:29 ----------
sorted - when passed as a variable the apostrophes are implicit. Finally got it working - thanks for those who input:
Works very nicely and you can include a here document then as so:
This will then echo "a" out and you can have a nice long list of commands from the here doc to run on the remote box. You can even log it locally as so:
---------- Post updated at 14:58 ---------- Previous update was at 14:57 ----------
NB QQ I've heard - why setup command as a var?
A: Because then you can generate it as a dynamic statement within a script - very handy!
I try to ssh uses bash script in here-document like this.
ssh root@$SERVER <<EOF
if ; then
service httpd start
fi
exit
EOF
But got an error below.
maybe the if command causes the problem. Thanks for help. (2 Replies)
I'm trying to use Here documents to pass several commands to a remote server over SSH. However I'm having problems. The code is as follows:
nohup ssh $i_hostname exec /usr/bin/ksh -s << EOF >> $AS_STOPSAP_LOG &
echo $i_instname;
ps -ef | grep name | grep ${i_instname} |grep -v grep
... (4 Replies)
Can we use a here document inside a here document?
Something like this
ssh user@remotehost << REMOTE
sudo vserver vsernamename enter << VSERVER
perform actions on vserver.
VSERVER
REMOTE (6 Replies)
Hi,
I have used nohup command to run a process in background. i ran successfully and i exit from that terminal. But when i login for the next time I am not able to see the process but it is working, since I am getting a e-mail alert for error issue. Please let me know how to bring that process... (3 Replies)
If i have a single file i would just press fg but if i have multiple files running in the backgound and want to bring a specific one to the foreground how would i do that? Thanks!! (1 Reply)
I'm not sure if it is even possible but I figured if it was someone here would know how to do it...
I am running a script which starts a bunch of processes in the background but there is one process I would like to bring back to the foreground when complete. Unfortunately the process that I... (2 Replies)
Hi :)
how can I use here doc to use ssh?
I am facing a problem with the below script:
#!/bin/bash
ssh hosein@localhost << *
123456
*
"123456" is my password
Thanks (2 Replies)
hi, i am just wondering that wen we give the following code we make a process run in background...can the viceversa be performed?i.e can this be made foreground again
# sleep 75&
21751
# (4 Replies)
Hi,
I am executing the SAS program using Unix script to call SAS program, but i would like to run that SAS program in forground mode, does anyone know what is command.
Thanks in advance!! (0 Replies)