learn more...One method to transfer files from the Windows command line is to use PSFTP. PSFTP creates an interactive SFTP file transfer session where you can use many of the commands available within a normal FTP session. Since PSFTP uses the SFTP protocol, which is only available with servers running protocol SSHv2, you may not be able to run it on every server. PSFTP is run from the command line and provides numerous options. To see the options available run PSFTP with the –h option: C:\>psftp -h Once you have started PSFTP, you will be placed into the PSFTP shell where you can connect to a remote machine (if you have not already done so), transfer files and modify file and directory attributes. To view a list of the commands available and what they do, run the help command from within the PSFTP shell: psftp> help The following is an example PSFTP session showing how to connect to remote server server.example.com as user sshuser and transfer files. Click on the Start Menu and select Run. In the field provided, type in cmd if you are running Windows NT/2000/XP or command if you are running Windows 9x/ME and click on the OK button. Next, type psftp at the command line and you will be placed into a PSFTP shell. Remember, you must have the path to the PuTTY executables defined within your Windows environment variable "PATH" in order for this to work. C:\> psftp Open a connection to the remote machine by invoking the open command with the following syntax: where user is the optional user ID you will connect to the remote machine as and hostname is the name or IP address of the host to which you will connect. You can alternatively specify the remote host and user name when invoking PSFTP from the command line. If you have not connected to this machine previously, you may be asked whether or not you want to cache the host key. Once the connection to the machine is open, you will be prompted for authentication. Upon successful authentication, the connection to the remote machine will have completed and the transfer of files can begin. psftp> open sshuser@server.example.com Next, you should verify the current local directory. This is done with the lpwd command. If you are not within the correct directory, the current local directory can be changed with the lcd command which takes a directory name as its argument. For example: psftp> lpwd Once you are within the correct local directory, you can change to the correct directory on the remote machine. This is done using the pwd and cd commands. The pwd command will print the remote connection's current directory and cd will change the remote connection to the directory provided as an argument. psftp> pwd Now that you are within the correct remote directory, you can verify that the file to download is present. This is done using the dir command. The dir command will display a UNIX-style listing of the current remote directory: Note For those familiar with UNIX, the "ls" command can be used in place of "dir". Use the "help" command to see a full listing of commands available. psftp> dir Use the get command to download remote files. The get command's syntax is as follows: get remote-filename[local-filename] where remote-filename is the name of the file you wish to download. You can optionally specify a new name for the downloaded file with the local-filename argument: psftp> get test.pl You have seen the PSFTP lpwd command to show the current local directory and the lcd command to change the current local directory, but there are no commands to see the contents of the local directory. To accomplish this, you can use the "!" command. The "!" command will execute the supplied OS command and receive and display whatever output is returned. So, in order to see if a file you wish to upload is present in the current local directory - test.sh in this case - we will use the "!" command with dirtest.sh as its arguments. psftp> !dir test.sh Volume in drive C has no label. Directory of C:\temp 07/10/02 03:03p 165 test.sh You can upload files to the remote server using the put command. The syntax for the put command is as follows: put local-filename[remote-filename] where local-filename is the name of the file you wish to upload. You can also optionally specify a new name for the file to be uploaded as with the remote-filename argument. psftp> put test.sh To close down a PSFTP connection, issue the bye command and you will be returned to the Windows command prompt: psftp> bye C:\> |
||||||
Disclaimer
1) E-articles is not responsible for the information contained by this article as well for any and all copyright infringements by authors and writers. E-articles is a free information resource. If you suspect this article for any copyright infringement, please read the terms of service and contact us to investigate the problem.
2) E-articles is not responsible for inaccuracies, falsehoods, or any other types of misinformation this article may contain and will not be liable for any loss or damage suffered by a user through the user's reliance on the information gained here. link to this article |