Topic "Need to abort ExecuteCommand before it returns"

Author Message
yoav
[View user's profile]

Joined: 2015-12-28
Posts: 2
Hi,

I am using .NET assembly with csharp.

I send command to remote server with ExecuteCommand method.

this command at the remote server does not stop alone but only with CTL C

so in my c sharp code - ExecuteCommand method dose not return and cpu is stuck in this line.

is there any way to ecutes command on the remote server with no waiting to the remote server output?

do you have an idea how can I solve this issue?

thanks alot
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
On a typical *nix server, you can run a command on a background using & operator, to avoid blocking the shell.

E.g.: session.ExecuteCommand("sleep 1000 &").Check();
yoav
[View user's profile]

Joined: 2015-12-28
Posts: 2
Hi Prikryl.

Thanks for the answer.

I tried to run the command on backround but got an error:

for the code:
CommandExecutionResult cmdExResult;
cmdExResult = curSession.ExecuteCommand("sleep 10000 &");


cmdExResult.outpot is:

"-bash: line 40: syntax error near unexpected token `;'\n-bash: line 40: `sleep 10000 & ; echo \"WinSCP: this is end-of-file:$?\"'"

can you please advise?

Thanks
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
True. You have to work it around by using something like:

echo "sleep 1000 &" > /tmp/sleep_on_background.sh ; bash /tmp/sleep_on_background.sh
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