Sunday, February 6, 2011

Copy files from local machine to remote server

If you waste the time copying files from your local machine to remote server .


#!/bin/bash
clear

echo '------------< START Uploading Files >------------'
for x in `cat $1`
do
echo ' ---> Copy file ( '$x' ) to Remote Server...'
sshpass -p 'REMOTESERVERPASSWORD' scp -P PORTNUMBER /your/files/path/$x REMOTEUSERNAME@REMOTEIPADDRESS:/your/remote/files/path/$x
done

echo '------------< END Uploading Files >--------------'



How it works :

list your files into text file as below :


admin/test.php
index.php


save the bash file at your local machine with this name : copy_files.sh


Run the bash file :


fadi@fadi-desktop:~/NetBeansProjects$ ./copy_files.sh files_list.txt


-------------------< START Uploading Files >-----------------
---> Copy file ( admin/test.php ) to Remote Server...
---> Copy file ( index.php ) to Remote Server...
-------------------< END Uploading Files >-------------------


DONE !!!!


No comments: