1837932 Members
2869 Online
110124 Solutions
New Discussion

at job

 
SOLVED
Go to solution
Charles Pfeiffer_1
New Member

at job

Hey everyone,
I'm writing a complex script that will initiate several at jobs, among other things. The at jobs are getting initiated properly, but there is a problem inside the at job. The at job connects to another machine to get some information and then needs to continue processing. The problem is that when it connects to the other machine (ssh, remsh, whaterver) and exits the at job also exits with (sh: Terminated) instead of continuing to process. Here is a small example of the at job:

VARIABLE=$(ssh server "COMMANDS")
[ $VARIABLE = STRING ] && COMMAND

The problem is that it finishes line 1 and exits when the shell used to connect to the remote machine exits. It never gets to line 2.

This seems like normal at behavior. Is there any way to change this behavior? This would be too messy to contain separate files and due to the way the process flows it needs to make this connection first.

Any help is appreciated. Thanks.
4 REPLIES 4
Michael Schulte zur Sur
Honored Contributor

Re: at job

Hi Charles,

one thing, you want to check is the paths to commands inside the script. At does not supplay many environment variables. If the script does not find ssh, it aborts.

greetings,

Michael
Donny Jekels
Respected Contributor
Solution

Re: at job

test 2 items.

one -> in ssh
VAR=$(ssh -t "command")

second -> escape the double quotes
VAR=$(ssh \"command\")

can't recall which worked for me last time
peace
Donny
"Vision, is the art of seeing the invisible"
Charles Pfeiffer_1
New Member

Re: at job

The path and such were set correctly. As noted the command actually did run, but the at job exited after the command completed.

-t on ssh worked. After reading the man page for ssh I can see how this would make sense. For kicks I tried to get remsh to work and found that I could with a -n. Thanks.
Michael Schulte zur Sur
Honored Contributor

Re: at job

Hi Charles,

glad to hear, that it works now and thanks for the zero points.

Michael