[Solved] Not able to read the next line from a file after doing ssh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Not able to read the next line from a file after doing ssh
# 1  
Old 02-13-2013
[Solved] Not able to read the next line from a file after doing ssh

Hi,
I am trying to write a code, where it reads the jobnames from a file and checks for the logs in the server. If the log is not found in the first server, then it will ssh to the 2nd server and get the details from there. I will need to save the date in a variable.
But the problem is that, after doing that ssh, it is not able to read the next line. The script is ending there treating it as end of file.

Code:
#Checking in Dime2 if not available in DIME1
if [ -z "$job_start1_date1" ]
then
job_start1_date1=`ssh -l uiaa10 abc "grep $job1 /log/abc.com/ca7en2.out|tail -2|grep -i JOBTERM|cut -d \" \" -f11"`
job_start_time1=`ssh -l uiaa10 abc "grep $job1 /log/abc.com/ca7en2.out|tail -2|grep -i JOBTERM|cut -d \" \" -f12"`
fi

I am using a while loop to read the contents of the file. Please let me know on how to read the file as usual after the above statements.

Thanks
Ajay

---------- Post updated at 07:22 PM ---------- Previous update was at 06:38 PM ----------

Hi,
Code:
ssh -n

resolved the problem. It is working as expected now.


Thanks
Ajay

Last edited by jim mcnamara; 02-13-2013 at 09:52 PM.. Reason: Modifying the names
This User Gave Thanks to ajayakunuri For This Post:
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 read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies

2. Shell Programming and Scripting

While read line via ssh

Hi I have a question, Why below script does't work ?: #!/bin/bash cd /home/weblogic/ cp_date=`awk -F '/' '{print "/" $8 "/" $9 "/" $10}' file_ftp.txt` ssh node8@192.168.1.8 'while read line; do ls -l "$line"; done <<< "$cp_date"' >> lsl.txt When I am running this script localy... (2 Replies)
Discussion started by: primo102
2 Replies

3. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

4. Shell Programming and Scripting

[Solved] While read line and if statement not working

I'm looking for some help in figuring why my little bit of code will not process any entries other then the first one in my list. while read line ;do hostname=${line//\"} a=`ssh user@$hostname uptime;echo $?` if ];then dt=`date` touch... (6 Replies)
Discussion started by: whegra
6 Replies

5. Shell Programming and Scripting

[SOLVED] nawk FS using pipe read variables from file

I have a file data_1.out which contains: 1|abc mail|mail subject|mail body 2|def mail|mail subject|def mail body I am trying to read the variables from data_1.out and use them to print to 2 different files based on the id (first_column) The problem is I am not able to read the file... (8 Replies)
Discussion started by: sol_nov
8 Replies

6. Shell Programming and Scripting

[Solved] Read a .gz file line by line without using gzcat

Hi all Is there a way to read and process a gzip file line by line similar to a text file without using gzcat.. while processing a text file we will usually use the logic exec<sample.txt while read line do echo $line done Is there a similar way to process the gz file in the same... (4 Replies)
Discussion started by: aikhaman
4 Replies

7. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

8. Shell Programming and Scripting

[Solved] Read a line from one string till to another.... Unix scripting..

So i have a file which contains paths to JPG images separated by a space. I have to separate them each path to another file. So, I have to search all strings that start from /home/ and ends with .jpg or .png Then write each one to another file... Can you please help me on doing this???:cool: (11 Replies)
Discussion started by: hakermania
11 Replies

9. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

10. Shell Programming and Scripting

read line and ssh

Hi, I 'd like have a script to ssh to a list of hosts from a file name hosts_list. However, the script seem to exit out from the first line of the file #!/bin/bash X="hosts_list"; while read LINE do echo $LINE ssh $LINE hostname done < $X hosts_list file content: linux1 linux2... (3 Replies)
Discussion started by: phamp008
3 Replies
Login or Register to Ask a Question