Executing ksh script to remote server want output on same window


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Executing ksh script to remote server want output on same window
# 1  
Old 11-15-2014
Computer Executing ksh script to remote server want output on same window

I'm having a brain freeze moment. I've created a ksh script in AIX that ssh's to a remote server, executes some commands, and then logs out. All of this is sent to a file. I then have the script cat the file so i can see the output. Even though the cat command is outside of the remote session part; when the entire script completes my screen jumps to the top of the window.

How can I stop it from doing this? I just want it all on my screen without automatically jumping to the top of my screen.

Here's an example of my script:
Code:
#!/bin/ksh

server=username@12.5.5.1

ssh -t -t $server << EOF > /home/test/temporary.txt
cd bin
pwd
exit
\p
EOF

sed '2,5d' /home/test/temporary.txt > /home/test/location.txt
cat /home/test/location.txt
rm /home/test/temporary.txt

Here's my screen output:
Code:
# /home/test/testvar.ksh
username@12.5.5.1's password:     PASSWORD ENTERED HERE

Screen automatically jumps to the top of the screen:
Code:
#

I have to scroll up on my screen to view the output which I want to avoid, please advise:
Code:
Last login: Sat Nov 15 09:09:14 2014 from 12.5.5.1
[username@server ~]$ cd bin
[username@server bin]$ pwd
/home/user/bin
[username@server bin]$ exit
logout
#

# 2  
Old 11-15-2014
Does the remote account have a ~/.bash_logout or something similar for its shell?
# 3  
Old 11-16-2014
... or a login/.rc script that could issue a reset command? What be the remote shell? Are those two -t options to ssh necessary as you are running the script interactively? What does the \p do?
# 4  
Old 11-17-2014
Hello,
If I dont put "ssh -t -t" I would get the message "Pseudo-terminal will not be allocated because stdin is not a terminal."

I have removed the /p as that was a mistake on my end. I was just testing different options earlier Smilie

I know this is a dumb question but how can I check what the remote shell is?
# 5  
Old 11-17-2014
Login interactively and echo $0 or echo $SHELL. If you are looking for another username, you could grep username /etc/passwd and find it as the last entry..
# 6  
Old 11-17-2014
Its
Code:
/bin/bash

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to keep staying on remote server after executing a shell script with if then exit end statement?

i have a "if .. then exit end " in s shell script on remote servers. now the connection to the remote server got killed after i run this script on the remote servers. How do i run this script on remote hosts and still keep remote connections alive after executing the script. Thank you. (10 Replies)
Discussion started by: moonmonk
10 Replies

2. Shell Programming and Scripting

How to Append the output of a script running in remote server to a file in local server?

Hi guys, So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies

3. UNIX for Dummies Questions & Answers

Executing a script in remote server

Hi All, I have 2 servers A and B. I need to connect to server B from server A and execute a shell script in B which will create some files and i need to copy those files back to server A. Required easiest possible for perfoming above task. (1 Reply)
Discussion started by: Girish19
1 Replies

4. Shell Programming and Scripting

output from remote server during execution of a script

How to see the output from remote server during execution of a script ? I am executing a script (ls) from machine 1 but the o/p should be displayed in machine 2. Can I achieve this ? Example:- Machine 1:- # ls Machine 2:- (console) file1 file2 file 3 dir1 dir2 (0 Replies)
Discussion started by: frintocf
0 Replies

5. Shell Programming and Scripting

Executing local script/command on remote server

I have a command that I want to run on machine B from machine A. If I run the command on machine B locally, it works fine. Here is the command: for n in `find /data1/ -name 'ini*.ext'` ; do echo cp $n "`dirname $n `/` basename $n .ext`"; done From machine A, I issue this command ... (3 Replies)
Discussion started by: dirtyd0ggy
3 Replies

6. Shell Programming and Scripting

ksh script with Interactive ssh on remote server

HI Unix Gurus, I an stuck in an interesting issue, where I am trying to execute a script on remote server after ssh. The script on remote server is interactive,. Whenever it is called it hangs where it expects input from terminal and I have to terminate it. I have searched through fourm... (12 Replies)
Discussion started by: Jeevanm
12 Replies

7. Shell Programming and Scripting

Problem executing perl script on remote server

Hello, I am running in to a problem running a perl script on a remote server. I can run a simple script test.pl which contains just a print statment without issue by running ssh root@1.2.3.4 perl test.pl However, I have a more complex script that does not execute as expected. I think I... (3 Replies)
Discussion started by: colinireland
3 Replies

8. Shell Programming and Scripting

Executing remote server sqlplus

Hello Guys I have to compare flat file record to oracle table record count count which are on different servers I am taking the flat file record count from the server now I am connecting to remote server first and then running sqlplus But after connecting to remote server the sqlplus... (3 Replies)
Discussion started by: Pratik4891
3 Replies

9. 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

10. Shell Programming and Scripting

executing a remote location script from local server

hi i am having two servers one is local and remote(FTP)server.from local server i have to connect to remote server and execute a shell script i want to run a shell script(remote location) from my local server i am having some knowledge on ftp but i am not getting the result .please give ... (2 Replies)
Discussion started by: srivsn
2 Replies
Login or Register to Ask a Question