0

I have two shell scripts like

mem.sh

RESULT=$(awk {print} /proc/meminfo)
r="$(./test.sh)"
RESULT="$RESULT$r"
echo ${RESULT#* }
exit ${RESULT%% *}

test.sh

echo "HI"

When I execute mem.sh locally it will print memory info followed by HI without any error, but I am in need of executing that script in remote machine, I am doing it like below

cat mem.sh | ssh user@ip  >> result.txt

I am getting error like

unexpected EOF while looking for matching `"'
syntax error: unexpected end of file

I could't find solution, Please help me on this or Is there any way to do this?

Question #2: Is there any way to execute multiple shell scripts(available in local machine) in remote machine?

I am using linux machine.

saravanakumar
  • 1,747
  • 4
  • 20
  • 38
  • look at this - http://stackoverflow.com/questions/305035/how-to-use-ssh-to-run-shell-script-on-a-remote-machine – avivb Apr 12 '16 at 11:40
  • You can't run local scripts on a remote machine without sending them to the remote machine. – Etan Reisner Apr 12 '16 at 11:43
  • 1
    You get that error for that *exact* script? What shell is default on the remote host? Try a simpler script and see if you can get working correctly. Then try commenting out lines in `mem.sh` until you figure out which is broken (though none of them look like they are to me). Your `exit` command is broken however in that it will not provide `exit` with a numeric value. – Etan Reisner Apr 12 '16 at 11:46
  • Yes! @EtanReisner, I have tried without exit also. It gives same response. – saravanakumar Apr 12 '16 at 11:52
  • Yes, `exit` isn't causing the quote problem it is just *another* problem with your script. Can you show the output of `hexdump -C mem.sh`? – Etan Reisner Apr 12 '16 at 12:26

0 Answers0