Swiss File Knife
a command line
free external tools,
- download the free Swiss File Knife Base from Sourceforge. - open the Windows CMD command line, Mac OS X Terminal or Linux shell. - OS X : type mv sfk-mac-i686.exe sfk and chmod +x sfk then ./sfk - Linux: type mv sfk-linux.exe sfk and chmod +x sfk then ./sfk OS X and Linux syntax may differ, check the help within the tool.
sfk ftp host[:port] [options] [command [parms] sfk sft host[:port] The SFK FTP Client. sfk ftp hostname uses plain FTP protocol via port 21 to speak with any (non SFK) FTP server. sfk sft hostname uses SFT Simple File Transfer via port 2121 for better connectivity, file attributes and multi file transfer, with SFK SFT servers only. commands put x send a single file with name x get x receive a single file with name x mput x send multiple files of the current directory having x in their filename mput .ext send multiple files ending with .ext mget x receive multiple files from the ftp server having x in their filename mget .ext receive multiple files ending with .ext dir list the remote directory cd x change into remote directory x lcd x change into local directory x !mycmd execute local command mycmd bye exit with SFT only: cput x send new or changed files of the current dir. if the server time (zone) is incompatible this will not work and may send all files or never any files. cget x receive new or changed files of the current directory on the server. same restrictions apply as with cput. run cmd run remote command, if server allows. options -notify=h display an arrow in SFKTray 1.1 running on hostname h whenever files are actually sent. -raw force ftp protocol even when connected with an sfk ftp server. default under windows, since sfk 1.8.5, when using port 21. -sft allow sft protocol even when using port 21 with an sfk ftp server. you may also set variable set SFK_CONFIG=usesft -verbose list the transmitted ftp commands, and tell if SFK_FTP_USER/PW variable is used. helpful to get more infos in case of errors. -force continue transfer after errors. -quiet disable progress indicator and other output. -noprog no progress indicator during transfers. -user=x or -user x sends username x instead of anonymous. you may also set an environment variable like: set SFK_FTP_USER=myuser or set SFK_FTP_CUSER=myuser with the latter one being used only by the sfk ftp command, but not by sfk ftpserv. -pw=x or -pw x sends an authentication password x. you may also set an environment variable like: set SFK_FTP_PW=mypassword or set SFK_FTP_CPW=mypassword with SFT only: -noclone do not copy time stamps on put/get. -pres always preserve full file attributes, including readonly modes. default is to keep file writeable by file owner and to apply umask under linux. -verify extra verify by re-reading files after transfer and comparing against a transmitted md5 checksum. aliases sfk sft same as sfk ftp but using port 2121 sfk list ... +put same as: sfk list ... +sft ... cput to send only changed and new files. sfk list ... +putall same as: sfk list ... +sft ... mput to send all selected files. automatic IP expansion if you are in the same subnet as the target host, you may supply only the IP number's last part(s), e.g.: sfk ftp 23 ... == sfk ftp 192.168.1.23 ... sfk ftp 2.23 ... == sfk ftp 192.168.2.23 ... this feature may or may not work, depending on your operating system and number of network interfaces. add option -showip to see what the expanded IP is. transfer protocol selection since SFK 1.8.5, when using "sfk ftpserv" at the server and "sfk ftp" at the windows client, plain FTP protocol is used to avoid firewall restrictions via port 21. to use SFT Simple File Transfer for better connectivity and cput/cget support run the server as "sfk sftserv" and the client as "sfk sft", which will use port 2121. file attributes since SFK 1.6.7, when using the SFT protocol, linux file attributes are sent and written at the receiver, except for file owner 'rw' flags which are set by default to allow rewrite in future transfers. when sending from linux to windows attributes like 'x' get lost. problems and solutions: if sfk to sfk file transfer via port 21 is stopped with ECONNRESET or ECONNABORTED this is probably caused by a firewall. try option -raw to use plain FTP. alternatively use "sfk sftserv" on server and "sfk sft" at the client, which uses the unrestricted port 2121. read more under: sfk ftpserv -help return codes for batch files 0 no files sent 1 any files sent see also sfk ftpserv -help web reference http://stahlworks.com/sfk-ftp examples sfk ftp farpc put test.zip send test.zip to farpc sfk ftp -user=foo -pw=bar farpc put test.zip the same but with authentication sfk ftp 192.168.1.99:30199 get test.zip receive test.zip from 192.168.1.99 port 30199 sfk ftp farpc mput .cpp send all .cpp files of the local dir to farpc. subfolder contents are NOT included. sfk ftp farpc mget * receive all files from farpc's directory, overwriting everything in the local directory. sfk ftp hostname enter interactive mode, in which you can type the above commands directly. for example, !dir runs the command "dir" locally. sfk sel -today mydir .css .php +ftp farpc mput upload all .css and .php files changed today within the mydir folder to FTP server farpc. before doing so, make sure that farpc has the same folder structure (mydir at top level). sfk today mydir .css .php +ftp farpc cput similar as above, but checks also on farpc which of the selected files actually differ. IF using SFT with an sfk sft server: best practice is to run an sft (simple file transfer) server on the other PC or VM like: sfk sftserv -rw this will use port 2121, avoiding firewall and other restrictions that usually block use of ftp port 21. then the following can be used by an sfk client: sfk sft farpc get myfile.txt download myfile.txt instantly. if a local file exists with the same name then it is overwritten. sfk sft farpc mget myfile download all files having "myfile" in their name. sfk will show a "simulating" preview first. add -yes to really download the files. sfk sft farpc mput myfile send all files having "myfile" in their name. if files with same name exist at server then they are overwritten. sfk sft farpc get the\sub\dir\doc.txt by default, sfk sftserv allows deep direct access to files within folders. all required output dirs are created automatically. this deep access cannot be used with mget, mput and dir. sfk sel mydir .txt +sft farpc cput send all .txt files within mydir that changed since the last transmission to farpc. sfk filter filelist.txt +sft farpc mget mydir create a list with filenames, download the files listed therein from server farpc into a folder "mydir". sfk sft 192.168.1.100 cput .txt connect to server .100 and send all .txt files which are newer or were added in the local folder. sfk sft 2.100 cget .txt connect to a server like, for example, 192.168.2.100 and download all .txt files which are newer or were added in the remote folder. sfk sft farpc -pw mypw run "sh myscript.sh >tmp1.txt 2>&1" execute a command on the remote server, redirecting all output into a file tmp1.txt. requires an sfk sft server with option -run, AND -pw authentication on both sides. sfk today mydir +sft -quiet .100 cput -yes +sleep 3000 +loop check mydir every 3 seconds for files changed today and upload them to .100 if newer as on server. NOTE: existing files are overwritten without asking back. Make sure that ftp server and client are running in the correct directories, especially before mput/mget.
sfk is a free open-source tool, running instantly without installation efforts. no DLL's,
no registry changes - just get sfk.exe from the zip package and use it (binaries for
windows, linux and mac are included).
read more about all sfk functions here.