Welcome to the Linux Foundation Forum!

ssh read output

With the help of ssh i would like to execute script and redirect the output in my local file

$ssh -i keypair1.pem [email protected] -C sh /mnt/monitor.sh >> /root/imgManagementOutput.txt

source: monitor.sh

echo `cat /mnt/imageOutput.txt`

Source: /mnt/imageOutput.txt



Expected Output:



Actual Output:

line1 line2

I am looking for the output should be as "Expected Output" as it is not in a single line...


  • deemkadeemka Posts: 1
    Try it with
    echo "$(cat /mnt/monitor.sh)"
    echo "`cat /mnt/monitor.sh`"
  • pbulteelpbulteel Posts: 2
    Why not just
    cat /mnt/imageOutput.txt

    Why are you echoing the output of cat? (Which itself is basically "echoing" the text file?)

  • What happens if you don't redirect the output to a file? Does it look right then? What about if you log onto <host> and run /mnt/monitor.sh. Does it look right when you're not piping through ssh? Try and strip away as much as you can and you'll probably find where the problem lies.
Sign In or Register to comment.