0

I am trying to run a .sh script on a remote server and am getting the following error message.

Really not sure what I am doing wrong.

The command I am using is: $ssh user@remoteserver path of file to be executed/Test.sh

Which returns the error: ksh: syntax error: `(' unexpected

Any pointers would be great :)

6
  • You are trying to execute a script stored at a remote site. The shell script that you are trying to execute has syntax errors. To fix this, you need to get the script code and do the necessary modifications. Commented Oct 31, 2012 at 12:38
  • I had thought this initially. But the remote script is just a simple test script and when I ran on the remote sever it worked perfectly. Hence my confusion :( Commented Oct 31, 2012 at 12:46
  • It may be something that's shell specific. Maybe the script isn't written for the k shell, which is being used to run the script. Commented Oct 31, 2012 at 12:50
  • If it is a shell-specific issue, then add the name of the shell to use to the front of the command like bash path/to/script, or, make sure the script has an appropriate #! as the first line so the correct shell is automatically selected. Commented Oct 31, 2012 at 13:25
  • I have included the #!/bin/ksh line at the beginning of the script Commented Oct 31, 2012 at 14:01

1 Answer 1

2

If Machine A is a Windows box, you can use Plink (part of PuTTY) with the -m parameter, and it will execute the local script on the remote server.

plink root@MachineB -m local_script.sh

If Machine A is a Unix-based system, you can use:

ssh root@MachineB 'bash -s' < local_script.sh

You shouldn't have to copy the script to the remote server to run it.

Source: How to use SSH to run a shell script on a remote machine?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.