Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Define folders
- THEFOLDER='/mnt/my/folder'
- # List files
- THEFILES=`ls -p $THEFOLDER | grep -v "/"`
- for file in $THEFILES
- do
- echo "Processing $file"
- lftp -u login,password -e "put $THEFOLDER/$file;quit" theftp/sub/folder
- done
- pip install paramiko
- import paramiko
- username = 'my_username'
- password = 'my_password'
- transport = paramiko.Transport((server, 22))
- transport.connect(username=username, password=password)
- sftp = paramiko.SFTPClient.from_transport(transport)
- local_filename = '/tmp/filename'
- remote_filename = 'MyFiles/temp.txt'
- sftp.put( local_filename, remote_filename )
- USING PASSWORDS
- FTP
- To ftp files using name+passwd, include them in the URL like:
- curl ftp://name:passwd@machine.domain:port/full/path/to/file
- or specify them with the -u flag like
- curl -u name:passwd ftp://machine.domain:port/full/path/to/file
- FTPS
- It is just like for FTP, but you may also want to specify and use
- SSL-specific options for certificates etc.
- Note that using FTPS:// as prefix is the "implicit" way as described in the
- standards while the recommended "explicit" way is done by using FTP:// and
- the --ftp-ssl option.
- SFTP / SCP
- This is similar to FTP, but you can specify a private key to use instead of
- a password. Note that the private key may itself be protected by a password
- that is unrelated to the login password of the remote system. If you
- provide a private key file you must also provide a public key file.
- #!/bin/bash
- expect -c "
- spawn sftp username@your_host
- expect "assword"
- send "your_password_herer"
- interact "
- chmod +x sftp_autologin.sh
- ./sftp_autologin.sh
- #!/bin/bash
- expect -c "
- spawn sftp myuser@myserver.com
- expect "assword"
- send "yourpasswordr"
- expect "sftp"
- send "get your_directory/yourfilename.txtr"
- expect "sftp"
- send "exitr"
- interact "
Add Comment
Please, Sign In to add comment