Sponsored Content
Top Forums Shell Programming and Scripting Getting SSH Output From Remote to Local Session? Post 302981382 by Don Cragun on Monday 12th of September 2016 12:05:56 AM
Old 09-12-2016
You can choose not to show us your script and we can make lots of wild assumptions. Or, you could show us your complete script with proprietary information redacted. Instead you have shown us two other scripts. All I can do at this point is comment on the script you provided in post #3 in this thread (shown here with trailing spaces replaced by <space>:
Code:
#! /bin/bash  

ssh -t -t $tar_host & <<EOF<space><space>
sleep 2<space>
echo "On host03"<space>
EOF<space><space>
echo "worked?"<space>
exit 0

Comments:
  1. An asynchronous command in a shell script ends with the & that makes the preceding command asynchronous. Therefore, the here-document in this script does not provide input to the ssh command (ssh -t -t). Note that I left out $tar_host because nothing in this script sets it, you have given no indication that it is supplied a value and exported by the invoking shell, and you have stated that it no variables are passed into the script by defining them on the command line when you invoke the script.
  2. Why did I mark the trailing spaces in your script? Although most of them do not matter, trailing spaces following the delimiter in a here-document prevent the shell from recognizing that line as a terminator for that here-document.
  3. So, from #1 and #2 above, we have an ssh command with no host specified, no login specified, and no commands to be executed; and we have an unterminated here-document with no command defined to read the data in that here-document.
If what you are trying to do is to run ssh on host03 feeding it two commands in a here-document, you might want something more like:
Code:
#! /bin/bash  
tar_host="host03"
{  ssh -t -t $tar_host <<EOF
   sleep 2
   echo "On host03"
EOF
}&
echo "worked?"<space>
exit 0

This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

mac 10.4>terminal>linux remote server>ssh login accepted>session closed-why?

mac 10.4>terminal>linux remote server>ssh login accepted>session closed-why? AHHHH!! I have been connecting to the server with the line: ssh userid@website.com The remote server accepts my password; logs me in with ssh; posts a lovely welcome message AND closes the session. Is this a "term... (0 Replies)
Discussion started by: xprankard
0 Replies

2. Shell Programming and Scripting

rsh help - getting the output of remote script to local server.

Hi, I have a script that runs for an hour. Have to run it on remote server and need the output it produces on the remote server to decide for failure or success. I run it through a Autosys Job which logs the outputs, both 1 & 2. I use the commands 1) rsh <SERVER> 'nohup /tmp/xyz.ksh &' 2)... (5 Replies)
Discussion started by: aster007
5 Replies

3. Solaris

How to reconnect to a disconnected remote ssh session

hi all How to reconnect to a disconnected remote ssh session on solaris 10 is there any way (4 Replies)
Discussion started by: h@foorsa.biz
4 Replies

4. Linux

Create VNC Session on remote machine on which ssh access is denied

Hi Folks, I want to create VNC session on the Remote RHEL machine on which ssh access is denied. Is there any way so that I can create VNC session without ssh access. Let me know all possible ways! (1 Reply)
Discussion started by: gydave
1 Replies

5. Shell Programming and Scripting

ssh sending local variable to remote system

I am running a useradd script, which works locally but I want to take some of that local information and send it to a remote system, ssh keys are set up between the two systems. I am attaching the script, look at the section titled "Sending information to FTP2" Removed attachment, added... (0 Replies)
Discussion started by: slufoot80
0 Replies

6. Shell Programming and Scripting

How to Compare local & remote Files over ssh?

I want to make a script to compare list of files in terms of its size on local & remote server whose names are same & this is required over ssh. How can I accomplish this. Any help would be appreciated. (1 Reply)
Discussion started by: m_raheelahmed
1 Replies

7. Shell Programming and Scripting

Using expect to remote SSH and write to a local file

Hi Guys, So what I am trying to do is : Host A should do a SSH to Host B to F. Login to the remote host and gather the output of uptime and write to to a file in HostA. So by the end of the script, HostA should contain a file that contains the uptime output of Host B,C,D,E,F. Right now... (1 Reply)
Discussion started by: Junaid Subhani
1 Replies

8. AIX

Need to remote control client's ssh session

Is there a way that I can remotely control a user's ssh session so I can see what they are doing and walk them through the problem they are having on my AIX based application? (2 Replies)
Discussion started by: De@nneG
2 Replies

9. Shell Programming and Scripting

Unable to ssh and list files in local directory from remote.

#!/bin/bash script_work_dir="/home/websys/TEST_dpi_42_file_trnsfer_engine/PORT22/script_work_area" script_config_dir="/home/websys/TEST_dpi_42_file_trnsfer_engine/PORT22/script_config" dpi_sourceServerList=$script_config_dir"/dpi_sourceServerList" dpi_srvr_42="rtm@1.1.1.1"... (8 Replies)
Discussion started by: sadique.manzar
8 Replies

10. Shell Programming and Scripting

Grep remote multiple hosts output to local server

Hello all, i'm trying to create a report by greping a pattern on multiple remote hosts and creta a simple report, actually i did this, is ther any better way to do this. #!/bin/bash for host in `cat RemoteHosts` do ssh $host -C 'hostname 2>&1; grep ERROR /var/log/WebServer.log.2019-09-21... (0 Replies)
Discussion started by: charli1
0 Replies
All times are GMT -4. The time now is 07:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy