不是一个编程问题,但与许多程序员有关......
假设我已经打开了另一台计算机的SSH会话.
remote:html avalys $ ls
welcome.msg index.html readme.txt
remote:html avalys $
是否有任何命令可以在我的远程shell中键入,它会立即将当前目录中的一个文件(例如welcome.msg)传输到我的本地计算机,即
remote:html avalys $ stransfer welcome.msg
获取/home/avalys/html/welcome.msg到welcome.msg
/home/avalys/html/welcome.msg 100%23KB 23.3KB/s 00:00
remote:html avalys $
我知道这样做的唯一方法是在SSH会话中打开并行SFTP会话和CD到我当前的目录,这是远程管理服务器时的真正PITA.
编辑:我知道使用反向sftp/scp连接的可能性,但这涉及更多的打字.如果我只能键入一些命令的名称(例如"stransfer"),以及我想要传输的文件,那就太棒了.
我正在编写一个使用带有凭据的ftp服务器的程序.我正在尝试从服务器检索目录列表但是当我到达该行时:
string line = reader.ReadLine();
Run Code Online (Sandbox Code Playgroud)
我得到的字符串只包含:"无法打开"主机:/ lib1 \"."
如果我尝试获取另一行,则抛出下一个异常:远程服务器返回错误:(550)文件不可用(例如,找不到文件,没有访问权限).
我肯定(使用另一个ftp应用程序)知道ftp服务器上存在'lib1'目录并且我的凭据(用户名和密码)是正确的.
这是我的代码:
public class FTPClient
{
public string UserName { get; set; }
public string Password { get; set; }
public string IpAddress { get; set; }
public int Port { get; set; }
public FTPClient(string _userName, string _password, string _address, int _port)
{
UserName = _userName;
Password = _password;
IpAddress = _address;
Port = _port;
}
public void GetDirectoriesList(string _path)
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri("ftp://" +
IpAddress + _path)); …Run Code Online (Sandbox Code Playgroud) 我有一个批处理脚本,动态创建一些文件并生成四个文件,根据时间,日期等有一些随机的文件名.然后需要通过FTP将该文件上传到服务器.
截至目前,我的.bat文件有一行像"ftp -s:ftp.txt".Ftp.txt包含一些相当简单的FTP脚本:类似这样的东西 -
open ftp.myserver.com
username
password
put filename1.dat
put filename2.dat
put filename3.dat
put filename4.dat
Run Code Online (Sandbox Code Playgroud)
我想要做的是传入需要上传的文件名,然后将"put filename1.dat"替换为"put%file1%" - 其中%file1%是传入的文件名变量.
这可能吗?有谁知道怎么做?或者我的整个方法是错的?
我在命令行(终端)中使用ftp将多个数据文件从远程服务器传输到本地计算机.目录中有多个文件(~40个),我想将它们全部传输,而不必在每个文件的提示中回答"是".我尝试了mget*,但这只转移了第一个文件,然后弹出了第二个文件的提示.
我使用LFTP从服务器传输文件,遗憾的是无法识别PORT命令.我无法控制服务器(不知道服务器是什么),我必须使用主动模式.
这是命令行:
lftp -e 'debug 10;set ftp:passive-mode off; set ftp:auto-passive-mode no; ls; bye;' -u user,password ftp://ftp.site.com
Run Code Online (Sandbox Code Playgroud)
这是调试输出:
<--- 200 Using default language en_US
---> OPTS UTF8 ON
<--- 200 UTF8 set to on
---> OPTS MLST modify;perm;size;type;UNIX.group;UNIX.mode;UNIX.owner;
<--- 200 OPTS MLST modify;perm;size;type;UNIX.group;UNIX.mode;UNIX.owner;
---> USER xxxxx
<--- 331 Password required for xxxxx
---> PASS xxxxxx
<--- 230 User xxxxx logged in
---> PBSZ 0
<--- 200 PBSZ 0 successful
---> PROT P
<--- 200 Protection set to Private
---> PORT 172,16,133,11,146,168 …Run Code Online (Sandbox Code Playgroud) 我试图删除网址的最后一部分,它是一个FTP URL.
假设我有一个URL:> ftp://ftp.abc.com/public_html/somefolder/.删除最后一部分后,我应该将其作为:ftp://ftp.abc.com/public_html/.
我尝试使用stringByDeletingLastPathComponenet和URLByDeletingLastPathComponent,但他们没有正确删除最后一部分.它们会改变网址的整体外观.
例如,在使用上述方法之后,这里是我得到的URL格式:ftp:/ftp.abc.com/public_html/.它会删除"ftp://"中的一个"/",这会导致我的程序崩溃.
如何在不干扰URL其余部分的情况下删除最后一部分?
更新:
NSURL * stringUrl = [NSURL URLWithString:string];
NSURL * urlByRemovingLastComponent = [stringUrl URLByDeletingLastPathComponent];
NSLog(@"%@", urlByRemovingLastComponent);
Run Code Online (Sandbox Code Playgroud)
使用上面的代码,我得到的输出为: - ftp:/ftp.abc.com/public_html/
我不需要经历一个复杂的推送过程,每次我做一个小的改动需要几分钟才能完成,我想直接FTP访问Heroku服务器上的文件.
这可能吗?
编辑:似乎在上次更新后此问题不再存在,至少到目前为止
每当我尝试上传文件时,我都会在上传时获得以下错误和成功的组合.
[5/20/14 7:20 PM] Upload to ***
[5/20/14 7:20 PM] Failed to transfer file 'C:\wamp\www\***\wp-content\plugins\woocommerce\includes\class-wc-api.php': could not create FTP directory "ftp://ftp.***.com/woocommerce".
[5/20/14 7:21 PM] Upload to ***
[5/20/14 7:21 PM] Upload to *** completed in less than a minute: 1 file transferred (3.7 Kb/s)
[5/20/14 7:21 PM] Upload to ***
[5/20/14 7:22 PM] Failed to transfer file 'C:\wamp\www\***\wp-content\plugins\paymentez-wooc-gateway\index.php': could not close the output stream for file "ftp://ftp.***.com/paymentez-wooc-gateway/index.php".
Run Code Online (Sandbox Code Playgroud)

我已禁用我的防火墙,没有运气,我已尝试在ftp中的被动模式和同样的问题,我可以在同一个ftp帐户上使用filezilla上传相同的文件和文件夹,所以我认为问题是在phpstorm,不确定如果是我的错误或配置错误.我在其他网站托管在不同的服务器上有这个问题,我不太确定,但我不记得在Windows 7下有这个问题,现在我在Windows 8下.
有时它上传正常,大部分时间都失败了.
任何想法都非常感谢,谢谢.
我已经创建了一个SSIS包,用于从FTP服务器下载文件.当我调试包时,一切都很顺利.但是,当我将程序包作为Job步骤进行处理时,它有时无法连接.该作业每4小时重复一次,平均每个其他运行失败,错误:0xC002918F - 登录请求被拒绝.
该连接是匿名的,不需要密码
我已经测试了几个小时了,发现了一些信息:
我无法看到FTP服务器的设置.最让我困惑的是,一些已经完成的任务工作得很好而有些失败了.我没有发现任何规律性.
到目前为止我尝试了什么:
到目前为止没有运气.还有一些尝试成功,有些则没有.
编辑:
FTP服务器位于Simatic设备上.
本周,我每隔1小时保持一次,每隔30秒就会对设备进行一次ping操作.仍有一些SSID尝试没有成功,每次ping都会通过: - /
我正在尝试通过FTP将文件上传到服务器.根据 Apple文档, NSURLSession类支持FTP操作.
有一个着名的Apple开发者博客,也支持这一点.但是还不清楚NSURLSession API是否支持ftp上传?(我尝试了建议的方式并得到错误).
使用传统的CFFTPStreamRef方式 ,ftp上传工作正常,但在9.0中已弃用.标题说:CF_DEPRECATED(10_3,10_11,2_0,9_0,"对ftp请求使用NSURLSessionAPI")
任何想法,示例或链接,以获得帮助.我现在正在尝试这样的事情:
NSURL *url_upload = [NSURL URLWithString:@"ftp://username:password@thelink/myfolder/filename.zip"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url_upload];
[request setHTTPMethod:@"PUT"];
NSURL *docsDirURL = [NSURL fileURLWithPath:filePath];
NSURLProtectionSpace * protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:url_upload.host port:[url_upload.port integerValue] protocol:url_upload.scheme realm:nil authenticationMethod:nil];
NSURLCredential *cred = [NSURLCredential
credentialWithUser:userId
password:password
persistence:NSURLCredentialPersistenceForSession];
NSURLCredentialStorage * cred_storage ;
[cred_storage setCredential:cred forProtectionSpace:protectionSpace];
NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
sessionConfig.URLCredentialStorage = cred_storage;
sessionConfig.timeoutIntervalForRequest = 30.0;
sessionConfig.timeoutIntervalForResource = 60.0;
sessionConfig.allowsCellularAccess = YES;
sessionConfig.HTTPMaximumConnectionsPerHost = 1;
NSURLSession *upLoadSession = …Run Code Online (Sandbox Code Playgroud) ftp ×10
batch-file ×1
c# ×1
concurrency ×1
connection ×1
ftp-client ×1
heroku ×1
ios ×1
ios6 ×1
iphone ×1
lftp ×1
nsstring ×1
nsurl ×1
nsurlsession ×1
openssh ×1
phpstorm ×1
ruby ×1
sftp ×1
shell ×1
sql-server ×1
ssh ×1
ssis ×1
windows ×1