Hello,
I am trying to find a way to send several sequential commands via SSH to a remote box in a single command.
Thoughts so far:
1) Can I put them into a function and call the function within the ssh command?
e.g.
That would call the function locally, and feed its output into ssh.
Still, you cannot, since functions aren't exported across ssh calls. It's like running a fresh script. It knows nothing about your functions or environment...
Quote:
2) Can I use a command block?
Yes. You won't be able to use standard input for anything else, though.
Quote:
I get these messages:
It means what it says. stdin is not a terminal, it's a here-document, so it doesn't allocate a pseudo-tty.
Other than that, there's nothing wrong with it.
Quote:
Actually then is does run the commands BUT I'm not sure it's solid.
Nothing's actually going wrong. The shell's just complaining since its input isn't an interactive terminal.
Quote:
my final target is that I want to run this whole command in the background --- when I try and do this with nohup I still see these errors
E.g.
They're not errors, they're warnings.
I think you can avoid the warnings by running the shell in a manner so it doesn't expect stdin to be a terminal.
Quote:
I think it's quite an interesting one - can anyone advise on the best possible method for generating a set of commands to execute on a remote box via ssh; but with one SSH command?
If you want the deluxe version, the one I tend to use:
Running sh in this way should be quite safe, and using <<"EOF" makes sure nothing gets substituted into the here document, no substitution at all. The only way you can transfer in variables is with the "arg1" "arg2" "arg3" there, which become $1 $2 $3 ...
I have a script I'm creating to spawn netcat listeners on a remote server for copying files at high speeds. The issue I'm running into is that after running the "nohup nc -l -p 12345 | tar -xvf - &" commands I can't get the remote shell to terminate. I'm not sure if this is working as intended or... (2 Replies)
when i have a function definition and function call in my script , i am unable to run my script in background with nohup..
Help me out please..... (3 Replies)
I have a fairly simple script like so:
nohup java -jar program.jar >> log 2>&1 &
echo $! > pidfile
This works great when using ssh server "script.sh" but not when using ssh -t server "script.sh"
The solution I came up with was to call sleep after recording the child pid. My guess at the... (2 Replies)
Hi All,
Can someone help me in knowing the exact difference between nohup and &.
The definition is quite clear but i only want to know if i run my job using & and in between i hung up my terminal. (10 Replies)
I have a question.
I will be running a background process using nohup and & command at end. I want to send output to a file say myprocess.out.
So will this command work?
nohup myprocess.ksh > myprocess.out &
Thanks in advance guys !!!
:) (3 Replies)
I am trying to run a command. This is one of my attempts:
for i in fileservera; do ssh -t $i 'sudo ls /';doneThis works, and I see the directories. However, what I want to do now is start a process on the remote server such as /usr/bin/connectproc -standalonesudo /usr/bin/connectproc... (1 Reply)