如果你用powershell登镇亩录一台linux机器高段,需要往另外一台linux机器御念森传输文件
可以用下面的命令
scp filename remotehost:/tmp
$fileinf=New-Object System.Io.FileInfo("D:\My Documents\works\Downloads\2.txt")$listFTP = [system.net.ftpwebrequest] [system.net.webrequest]::create`("ftp://团岩灶115.*.*.*/"+$fileinf.name)
$listFTP.UseBinary = $true
$listFTP.Credentials = New-Object System.Net.NetworkCredential("username","passwold")
$listFTP.Method=[system.net.WebRequestMethods+ftp]::UploadFile
$listFTP.KeepAlive=$false
$sourceStream = New-Object System.Io.StreamReader($fileInf.fullname)
$fileContents = [System.Text.Encoding]::UTF8.GetBytes($sourceStream.ReadToEnd())
$sourceStream.Close()
$listFTP.ContentLength = $fileContents.Length
$requestStream = $listFTP.GetRequestStream()
$requestStream.Write($fileContents, 0, $fileContents.Length)
$requestStream.Close()
$response =$listFTP.GetResponse()
$response.StatusDescription
$response.Close()
以塌扮上是枣肆代码,以下是返回。
226 Transfer complete. 7,146 bytes transferred. 3.79 KB/sec.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)