同样由于某种原因,它昨天还在工作,但今天却不工作。我认为它不是代码,而是一些外部问题。
无论如何
Dim virtualFolder As String = "~/Scripts/"
Dim physicalFolder As String = Server.MapPath(virtualFolder)
Dim unixLogin As String = (USERNAME & "@" & COMPUTERNAME & ":" & UNIXSCRIPTNAME)
' Send file to Unix server via pscp
Dim Proc As New System.Diagnostics.Process
Proc.StartInfo = New ProcessStartInfo("C:\Windows\System32\cmd.exe")
'MsgBox("/C C:\pscp.exe -pw " & PASSWORD & " " & physicalFolder & "\" & UNIXSCRIPTNAME & " " & unixLogin)
Proc.StartInfo.Arguments = "C:\pscp.exe -pw " & PASSWORD & " " & physicalFolder & "\" & UNIXSCRIPTNAME & " " & USERNAME & "@" & COMPUTERNAME & ":" & UNIXSCRIPTNAME
Proc.StartInfo.RedirectStandardInput = True
Proc.StartInfo.RedirectStandardOutput = False
Proc.StartInfo.UseShellExecute = False
'Proc.StartInfo.CreateNoWindow = True
Proc.Start()
' Allows script to execute sequentially instead of simultaneously
Proc.WaitForExit()
' Make file executable
Proc.StartInfo = New ProcessStartInfo("C:\plink.exe")
'MsgBox("-ssh -pw " & PASSWORD & " " & USERNAME & "@" & COMPUTERNAME & " chmod u+x ./" & UNIXSCRIPTNAME)
Proc.StartInfo.Arguments = "-ssh -pw " & PASSWORD & " " & USERNAME & "@" & COMPUTERNAME & " chmod u+x ./" & UNIXSCRIPTNAME
Proc.StartInfo.RedirectStandardInput = True
Proc.StartInfo.RedirectStandardOutput = False
Proc.StartInfo.UseShellExecute = False
' Proc.StartInfo.CreateNoWindow = True
Proc.Start()
Proc.WaitForExit()
' Execute File
Proc.StartInfo = New ProcessStartInfo("C:\plink.exe")
Proc.StartInfo.Arguments = "-ssh -pw " & PASSWORD & " " & USERNAME & "@" & COMPUTERNAME & " ./" & UNIXSCRIPTNAME
Proc.StartInfo.RedirectStandardInput = True
Proc.StartInfo.RedirectStandardOutput = False
Proc.StartInfo.UseShellExecute = False
'Proc.StartInfo.CreateNoWindow = True
Proc.Start()
Proc.WaitForExit()
' Remove File
Proc.StartInfo = New ProcessStartInfo("C:\plink.exe")
Proc.StartInfo.Arguments = "-ssh -pw " & PASSWORD & " " & USERNAME & "@" & COMPUTERNAME & " rm ./" & UNIXSCRIPTNAME
Proc.StartInfo.RedirectStandardInput = True
Proc.StartInfo.RedirectStandardOutput = False
Proc.StartInfo.UseShellExecute = False
'Proc.StartInfo.CreateNoWindow = True
Proc.Start()
Proc.WaitForExit()
这个可以缩短吗?我是... 1) 将文件发送到 unix 系统 2) 使其可执行 3) 运行文件(它的脚本) 4) 之后删除它