Topic "Need to run a script in unix from windows c# application"

Author Message
Sam_9417

Guest


Hi,

I need to run my script file example.sh in the unix server so i use to run in unix like sh example.sh in the black window and that how it worked but i wanted to run it from the windows application. so i wrote the following code but it's not working. Any help will be great.

Process winscp = new Process();
winscp.StartInfo.FileName = "winscp.com";
winscp.StartInfo.Arguments ="/xmllog=xml.log";
winscp.StartInfo.UseShellExecute = false;
winscp.StartInfo.RedirectStandardInput = true;
winscp.StartInfo.RedirectStandardOutput = true;
winscp.StartInfo.CreateNoWindow = true;
winscp.Start();

winscp.StandardInput.WriteLine("option batch abort");
winscp.StandardInput.WriteLine("option confirm off");
winscp.StandardInput.WriteLine("Open new_user:new_user@123user");
winscp.StandardInput.WriteLine("sh home/user/new_directory/example.sh")
winscp.StandardInput.WriteLine("close");
winscp.StandardInput.Close()
string output= winscp.StandardOutput.ReadToEnd();

but it's not working. please any help me.
Advertisements
Sam_9417

Guest


Sorry i wrongly mentioned "sh example.sh" i am using call example.sh
Sam_9417

Guest


Sorry i wrongly mentioned "sh example.sh" i am using call example.sh
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
The "it's not working" means what? What does it do? Any error message?

Anyway, use WinSCP .NET assembly instead of driving the winscp.com on your own:
https://winscp.net/eng/docs/library
https://winscp.net/eng/docs/library_session_executecommand
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License