使用stdin重定向的WinSCP ExecuteCommand?

时间:2016-10-25 18:32:59

标签: c# linux stdin winscp winscp-net

鉴于:

Auditorium [auditorium=506, beginLesson=10:30, date=Mon Sep 12 00:00:00 BST 2016, dayOfWeekString=Monday, discipline=Math, endLesson=11:10, kindOfWork=Lesson, lecturer=John Smith]

咨询会话日志显示命令是否正确,其中包含:

var linuxCommmand = "/opt/ndmcli -x"; 
var linuxOptions = "sel stat pnum=157 detail=yes;\nquit;"; 
SSH.ExecuteCommand(String.Format("{0} <<!!\r\n{1}\r\n!!\r\n", linuxCommand, linuxOptions)); 

我有什么理由不能使用WinSCPNet的2016-10-25 14:12:49.433 Script: call /opt/cdunix/ndm/bin/ndmcli -x <<!! 2016-10-25 14:12:49.433 sel stat pnum=157 detail=yes; 2016-10-25 14:12:49.433 quit; 2016-10-25 14:12:49.433 !! 2016-10-25 14:12:49.433 Executing user defined command. 2016-10-25 14:12:49.433 /opt/cdunix/ndm/bin/ndmcli -x <<!! 2016-10-25 14:12:49.433 sel stat pnum=157 detail=yes; 2016-10-25 14:12:49.433 quit; 2016-10-25 14:12:49.433 !! ; echo "WinSCP: this is end-of-file:$?" 2016-10-25 14:13:04.437 Waiting for data timed out, asking user what to do. 2016-10-25 14:13:04.437 Asking user: 2016-10-25 14:13:04.437 **Host is not communicating for 15 seconds. 2016-10-25 14:13:04.437 2016-10-25 14:13:04.437 Wait for another 15 seconds?** () 进行stdin重定向吗?

谢谢!

**** **** UPDATE 奇怪的是,如果我添加一个尾随空格:

ExecuteCommand

一切正常:

var linuxCommmand = "/opt/ndmcli -x"; 
var linuxOptions = "sel stat pnum=157 detail=yes;\nquit;"; 
SSH.ExecuteCommand(String.Format("{0} <<!!\r\n{1}\r\n!!\r\n ", linuxCommand, linuxOptions)); 

1 个答案:

答案 0 :(得分:0)

新行将完全混淆WinSCP。

该命令实际上没有正确执行,因为尾部!!必须单独在一条线上,不是。

你必须把所有东西放在一行上。

这可行:

( echo sel stat pnum=157 detail=yes; & echo quit; ) | /opt/cdunix/ndm/bin/ndmcli -x