TERM environment variable not set
Hi All,
I am trying to execute a bash script from a centralized AIX machine to Linux boxes but i get the error saying "TERM environment variable not set". Below are my scripts and how i am using them to execute remotely. Code:
serv1:/ #ls -l rohit.sh Code:
#!/bin/bash Code:
serv1:/ #ssh serv2 'bash' < rohit.sh Code:
serv1:/ #ssh serv2 'bash' < rohit.sh So can anyone suggest. I also tried setting the TERM=xterm and then exporting it in the script but even that also didn't help. |
When you are running a remote command like that you don't get a terminal. I wouldn't include the "clear" commands.
|
hi linosaurusroot, thanks for yuor reply.removing "clear" actually resolved the error but i still end up at the prompt without my script being executed.
Here is the output after removing "clear" from the script Code:
serv1:/ #ssh serv1 'bash' < rohit.sh |
Perhaps the terminal type is not defined. What's result of:
Code:
~$ env | grep TERM Code:
serv1:/ # ssh serv2 'bash -xv rohit.sh' |
Quote:
Code:
#env | grep TERM |
The problem you're having is because you seem to be mistaken about where your standard IO redirection is occurring. The local host is redirecting the standard input of the ssh process from the script 'rohit.sh'. I surmise that your intention is to run the script under the bash process on the remote host. In order for that to happen, the script must exist on that remote host. The redirection you're using probably does nothing, since ssh doesn't know what to do with a shell script as input.
--- rod. |
Quote:
Code:
serv1:/ # ssh serv2 'bash -xv rohit.sh' |
Quote:
Code:
ssh <hostname> 'bash' < script.sh |
Quote:
|
If the script cannot be on the remote host, then your only recourse will be to feed the content of the script through the ssh connection. Probably the expect tool is the best way to accomplish that. You may also be able to run the ssh session from within a screen session. Using that method, you will be able to exploit screen's stuff command to push data into the screen session, and thus to the remote bash session. I have used this method with very good success in similar applications.
What about your local script including a line that uses scp to put the script onto the remote host before executing it? Your local script could then probably delete it from the remote host before closing the connection. --- rod. |
Quote:
Code:
scp rohit.sh root@serv2:/root >/dev/null |
Never had to use expect, since I always use the screen method. expect is probably required if you need to send data that depends on some condition observed in the response from the remote host.
This should get you close, using the screen method: Code:
NL=$(echo -ne '\015') --- rod. |
Quote:
ssh -t serv2 'bash' < rohit.sh giving a command (such as 'bash') causes ssh to not request a terminal. You also get a working result using ssh serv2 <rohit.sh as that requests a terminal to be assigned. |
All times are GMT -5. The time now is 04:36 PM. |