Reputation: 1
I connect to my remote server via ssh from the console
[mylocalserver]$ ssh -p 27 myremoteserver
On my remote server, I have a log file (mylogfile.log) that contains several lines
File mylogfile.log contains 10 lines
01 | Field 1 | Field 2
02 | Field 1 | Field 2
...
10 | Field 1 | Field 2
When I execute the tail command from the console of the server to which I am connected remotely, it returns the result as 5 different lines
[myremoteserver]$ tail /usr/tmp/mylogfile.log
Return
06 | Field 1 | Field 2
07 | Field 1 | Field 2
08 | Field 1 | Field 2
09 | Field 1 | Field 2
10 | Field 1 | Field 2
But when I run a script on my local server that includes the connection to the remote server and the tail command, I don't get the same result
File on my local server /usr/tmp/script.sh
contains
#!/bin/bash
result=`ssh -p 27 myremoteserver "tail \"/usr/tmp/mylogfile.log\""`
echo ${result}
When I execute the script on my local server...
[mylocalserver]$ /usr/tmp/script.sh
Return
06 | Field 1 | Field 2 07 | Field 1 | Field 2 08 | Field 1 | Field 2 09 | Field 1 | Field 2 10 | Field 1 | Field 2
How can I solve this problem so that when I run the script on my local server, the result returned is each line of the file on the remote server and not a single line with all the original lines concatenated?
I was hoping to get the same result when execute script
Upvotes: 0
Views: 18