‘壹’ 怎么用ftp 取文件 命令
熟悉并灵应用FTP内部命令便使用者并收事半功倍效
FTP命令行格式:ftp -v -d -i -n -g [主机名]其
-v显示远程服务器所响应信息;
-n限制ftp自登录即使用;
.n etrc文件;
-d使用调试式;
-g取消全局文件名
ftp使用内部命令(括号表示选项):
1.![cmd[args]]:本机执行交互shellexitftp环境:!ls*.zip.
2.$ macro-ame[args]:执行宏定义macro-name.
3.account[password]:提供登录远程系统功访问系统资源所需补充口令
4.append local-file[remote-file]:本文件追加远程系统主机若未指定远程系统文件名则使用本文件名
5.ascii:使用ascii类型传输式
6.bell:每命令执行完毕计算机响铃
7.bin:使用二进制文件传输式
8.bye:退ftp程
9.case:使用mget远程主机文件名写转写字母
10.cd remote-dir:进入远程主机目录
11.cp:进入远程主机目录父目录
12.chmod mode file-name:远程主机文件file-name存取式设置mode:chmod 777 a.out
13.close:断与远程服务器ftp(与open应)
14.cr:使用asscii式传输文件车换行转换行
‘贰’ windowsftp如何获取文件夹下所有的文件
可以通过命令窗口来打开所有的文件。具体步骤如下:
点击win+R后输入cmd打开dos命令窗口。
打开需获取文件名的位置。
获取名称,命令格式:dir/b文件目标盘符文件夹位置(可省略)目标名称.目标后缀。
获取文件大小及文件名、修改时间(文件大小需处理)。
Microsoft Surface是一个由微软所开发的第一款平面电脑,结合硬件与软件的新技术,用家可以直接用手或声音对屏幕作出指令,触摸和其他外在物理物来和电脑进行交互,毋须再依赖会令手部劳损的鼠标与键盘。
‘叁’ 如何使用bat命令直接下载指定ftp上面的指定文件
ftp下载文件一般步骤如下:
echo open xxx.xxx.xxx.xxx >ftp.txt
echo user >>ftp.txt
echo password >>ftp.txt
echo binary >>ftp.txt [可选]
echo get srv.exe >>ftp.txt
echo bye >>ftp.txt
ftp -s:ftp.txt(这一步是关键哟)
del ftp.txt
存为*.bat
‘肆’ c++如何读取ftp上指定的文件
#include<fstream>
using namespace std;
ifstream cin(""/*ftp地址*/);
int main()
{
int a;
cin>>a;
cin.close();
return 0;
}
‘伍’ 如何在ftp中搜索指定文件
可以用asp的fso组件(也就是FileSystemObject)对文件进行搜索
‘陆’ python ftp连接指定服务器,并下载指定文件
ftp客户端一般只有显示、上传、下载,并没有打开文件的操作,所以你得先下载相应配置文件,在本地解析后,再继续用相关参数下载后续文件。
‘柒’ 如何设置指定用户名通过ftp访问指定共享文件
Linux添加FTP用户并设置权限在linux中添加ftp用户,并设置相应的权限,操作步骤如下:1、环境:ftp为vsftp。被限制用户名为test。被限制路径为/home/test2、建用户:在root用户下:useradd-d/home/testtest//增加用户test,并制定test用户的主目录为/home/testpasswdtest//为test设置密码3、更改用户相应的权限设置:usermod-s/sbin/nologintest//限定用户test不能telnet,只能ftpusermod-s/sbin/bashtest//用户test恢复正常usermod-d/testtest//更改用户test的主目录为/test4、限制用户只能访问/home/test,不能访问其他路径修改/etc/vsftpd/vsftpd.conf如下:chroot_list_enable=YES//限制访问自身目录#(defaultfollows)chroot_list_file=/etc/vsftpd/vsftpd.chroot_list编辑vsftpd.chroot_list文件,将受限制的用户添加进去,每个用户名一行改完配置文件,不要忘记重启vsFTPd服务器[root@linuxsir001root]#/etc/init.d/vsftpdrestart5、如果需要允许用户修改密码,但是又没有telnet登录系统的权限:usermod-s/usr/bin/passwdtest//用户telnet后将直接进入改密界面
‘捌’ C# 获取Ftp某个目录下的所有文件(不要文件夹)
我在之前做过一个FTP的客户端工具。
drw 文件夹
-rw 文件(有扩展名或无扩展名)
我是根据服务端返回的报文进行分析获取的列表。
给你一些代码片段:
/// <summary>
/// 获取指定目录下的文件和文件夹。
/// </summary>
/// <param name="path">要获取的目录</param>
/// <param name="WRMethods">要发送到FTP服务器的密令。</param>
/// <returns></returns>
public string[] GetFileList(string path, string WRMethods)//从ftp服务器上获得文件列表
{
WebResponse response;
string[] downloadFiles;
int conut = 4;
StringBuilder result = new StringBuilder();
Connect(path);
if (FTPVariable.IsUseProxy_ftp)
{
reqFTP.Proxy = FtpProxy.GetFtpSelectProxy(FTPVariable.FtpCommand_transferProxyName);
}
reqFTP.ReadWriteTimeout = 12000;
//如果不应销毁到服务器的连接,则为 true;否则为 false。默认值为 true。
//
reqFTP.Method = WRMethods;
try
{
response = (FtpWebResponse)reqFTP.GetResponse();
goto Ftp_lbl_03;
}
catch (WebException webex)
{
GetReply(webex.Message);
if (ReplyCode == 530)// 未登录。
{
goto Ftp_lbl_04;
}
else if (ReplyCode == 550)
{
goto Ftp_lbl_04;
}
else
{
FtpManage.SetLog("获取列表超时,等候1秒后重试!");
goto Ftp_lbl_01;
}
}
Ftp_lbl_01:
try
{
FtpManage.SetLog("正在连接服务器 " + FtpRemoteHost);
response = GetRequest(path, WRMethods);
}
catch (WebException)
{
FtpManage.SetLog("获取列表超时,等候1秒后重试!");
downloadFiles = null;
System.Threading.Thread.Sleep(1000);
if (conut == 0)
{
goto Ftp_lbl_02;
}
conut--;
goto Ftp_lbl_01;
}
catch (Exception ex)
{
MSG.Show(ex.Message, Global.GetRS["msgTilteError"], MessageBoxButton.OK, MsgIco.Error);
FtpManage.SetLog("命令执行失败,原因:" + ex.Message);
downloadFiles = null;
return downloadFiles;
}
Ftp_lbl_03:
StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);//中文文件名
string line = reader.ReadLine();
while (line != null)
{
result.Append(line);
result.Append("\n");
line = reader.ReadLine();
}
if (result.Length == 0)
{
return null;
}
// to remove the trailing '\n'
result.Remove(result.ToString().LastIndexOf('\n'), 1);
reader.Close();
response.Close();
FtpManage.SetLog("命令已成功执行");
return result.ToString().Split('\n');
Ftp_lbl_04:
FtpManage.SetLog(ReplyInfo);
return null;
Ftp_lbl_02:
FtpManage.SetLog("550 获取列表失败,无法连接远程服务器!");
FtpManage.ftpmanage.IsRefurbish = true;
return null;
}
/// <summary>
/// 获取指定目录下的文件和文件夹。
/// </summary>
/// <param name="path">要获取的目录</param>
/// <returns></returns>
public string[] GetFileList(string path)//从ftp服务器上获得文件列表
{
return GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/" + path, WebRequestMethods.Ftp.ListDirectory);
}
/// <summary>
/// 获取指定目录下的文件和文件夹。
/// </summary>
/// <returns></returns>
public string[] GetFileList()//从ftp服务器上获得文件列表
{
return GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/", WebRequestMethods.Ftp.ListDirectory);
}
/// <summary>
/// 获取目录和文件名,返回目录表。
/// </summary>
/// <param name="path">要获取的目录</param>
/// <returns></returns>
public string[] GetCatalog_FileList(string path)
{
string[] fountainhead = GetFileList(FTPVariable.FtpURLhead + FtpRemoteHost + "/" + path, WebRequestMethods.Ftp.ListDirectoryDetails);
string[] Catalog = null;
if (fountainhead == null)
{
return null;
}
Catalog = new string[fountainhead.Length];
for (int i = 3; i < fountainhead.Length; i++)
{
Catalog[i - 3] += fountainhead[i].Substring(55, fountainhead[i].Length - 55) + "&";//FileName
Catalog[i - 3] += fountainhead[i].Substring(30, 12) + "&";//FileSize
Catalog[i - 3] += fountainhead[i].Substring(42, 13) + "&";//AmendDate
Catalog[i - 3] += fountainhead[i].Substring(0, 3) + "&";
}
return Catalog;
}
‘玖’ 如何获取ftp服务器下指定文件的大小
//////获取ftp服务器上指定文件夹的文件列表(包含文件大小)//////////////////publicDictionaryGetFTPList(stringServerIP,stringUSERID,stringPassWord,stringpath){Dictionarydic=newDictionary();if(path==null)path="";FtpWebRequestreqFtp;try{reqFtp=(FtpWebRequest)FtpWebRequest.Create(newUri("ftp://"+ServerIP+"/"+path));reqFtp.KeepAlive=false;reqFtp.UseBinary=true;//指定ftp数据传输类型为二进制reqFtp.Credentials=newNetworkCredential(USERID,PassWord);//设置于ftp通讯的凭据reqFtp.Method=WebRequestMethods.Ftp.ListDirectoryDetails;//指定操作方式WebResponseresponse=reqFtp.GetResponse();//获取一个FTP响应StreamReaderreader=newStreamReader(response.GetResponseStream(),Encoding.GetEncoding("GB2312"));//读取响应流stringline=reader.ReadLine();while(line!=null){if(line!="."&&line!=".."){intend=line.LastIndexOf('');intstart=line.IndexOf("");stringfilename=line.Substring(end+1);if(filename.Contains(".")){line=line.Replace(filename,"");dic.Add(filename.Trim(),int.Parse(line.Substring(start).Trim()));}}line=reader.ReadLine();}}catch(Exceptionex){Console.WriteLine(ex.Message);}returndic;}文件夹或者某一文件都适用