1

I have done the following steps successfully:

  1. I have created an WinSCP [Process] in C# .NET
  2. Created a Session of a user on LINUX-server [Using SFTP Protocol]
  3. Downloaded the files using GetFiles(........);

The thing I want to add to my App is that:

  • Give that process a command to run a shell-script [already uploaded on the server]
  • I tried this session.ExecuteCommand("sh /fol1/fol1_1/abc.sh");
    but giving no results/impacts
6
  • 1
    Though I'm still confused by your reference to Process and winscp.StandardInput. That does not go well with WinSCP .NET assembly. It would really help, if you post your code. Commented Apr 30, 2015 at 7:28
  • Thanks @MartinPrikryl . Updated the Question's last bullet. No error while running but the files are not being created in the directory using abc.sh . Though the abc.sh is working when i manually run it from putty Commented Apr 30, 2015 at 8:29
  • When running in PuTTY, do you execute it using the same syntax (sh /fol1/fol1_1/abc.sh) from the root folder? Commented Apr 30, 2015 at 8:37
  • i go to the directory using cd first then simply: sh abc.sh Commented Apr 30, 2015 at 10:36
  • 1
    So try the same with WinSCP: session.ExecuteCommand("cd /fol1/fol1_1; sh abc.sh"); Commented Apr 30, 2015 at 10:43

1 Answer 1

2

To execute a shell command on the server using WinSCP .NET assembly, use the Session.ExecuteCommand:

session.ExecuteCommand("sh abc.sh");

This will work with the SCP and the SFTP (with limitations) protocols only.
See https://winscp.net/eng/docs/library_session_executecommand#remarks

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.