user3930361
user3930361

Reputation: 181

How To Run a Script in WinSCP

I am using winSCP GUI to connect to linux terminal and then copy the files and other stuff.

Now i have some scripts on the UNIX server,I am connected but how to run the script from the Win SCP.

what basically is needed is sh scriptname.sh through the WinSCP.Please let me know if anyone else found out how to do that.AS loging into putty and running the command is time taking for me. WinSCP Custom Command option tried to click on Execute,but the error pops up like no such directory.

Tried google but to the point information is not coming up.

Upvotes: 5

Views: 20587

Answers (4)

Martin Prikryl
Martin Prikryl

Reputation: 202168

  • To execute an ad-hoc shell command in WinSCP, use the Console window:

    WinSCP Console window

  • To execute the shell script selected in a file panel, create a custom command like:

    sh "!"
    

    This is actually, what the pre-defined custom command Execute (almost) does.

    I'm aware that you claim that this does not work. But it should work in general. If you are having problems, please tell us details (exact error message, screenshot, anything)

  • You can have WinSCP open PuTTY terminal client and execute the commands there.

    With some setup you can even open the PuTTY in the same directory as you have opened in WinSCP file panel.

  • Particularly for long-running commands/scripts, you can create a local custom command that runs the script via Plink:

    "C:\Program Files (x86)\PuTTY\plink.exe" -ssh !U@!@ "!/!" 
    

    Check the Use remote files option. Do not forget to select the Local command.

    You can also pass the command to PuTTY to using similar method as used for Opening PuTTY in the same directory.

Upvotes: 0

NeverGiveUp161
NeverGiveUp161

Reputation: 850

Try this sh "!"

OR

First of all executing commands from WinSCP can be tricky and if you are able to run few commands also,there are restrictions which you can not do fro WinSCP and should have to ultimately take help of PUTTY.

Here is the link Integrate WinSCP with Putty which will help you integrate your WinSCP to Putty,so that when you open any server through WinSCP putty will automatically connect without even asking for the password.And then you can run you command,hope that wound be of any trouble to you.

Remember you can store the connection details in WinSCP and in just one click it will connect to the server on SCP and also on Putty.

Upvotes: 3

IBam
IBam

Reputation: 11794

You can define your own custom command by right-clicking, selecting Custom commands and selecting Customize. Then click "Add", enter a description, e.g. Run and specifying a custom command. Try sh "!" to start with - that works ok for me, if you still get errors post your output back here. The quotes are important - only the exclamation should be quoted.

Upvotes: 2

William
William

Reputation: 11

Right click the script > Custom Commands > Execute

Hope this helps.

Upvotes: 1

Related Questions