Dear Readers,
In this article, we will see the following Transfer Files from One Server to Another Server Using SFTP.
Login as root and install sshpass package :
1 2 |
[oracle@db2 u01]$ su - root [root@db2 ~]# yum install sshpass |
Create text file and Create .sh file
Create text file :
1 |
[oracle@db2 u01]$ vi demo.txt |
Create .sh file :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[oracle@db2 u01]$ vi sftp.sh ************************************************** **** sftp.sh ************************************************** sshpass -p password sftp username@Target_server_IP <<EOF lcd /u01/ -- Source Path cd /u01/ -- Target path mput demo.txt quit EOF SFTP_RETURN_CODE=${?} if [[ 0 != ${SFTP_RETURN_CODE} ]] then echo "File upload failed" exit ${SFTP_RETURN_CODE} else echo "File upload successful" fi exit 0 |
Execute the sh file :
[oracle@db2 u01]$ sh sftp.sh
Check Installed package :
1 2 3 4 |
[root@db2 ~]# yum list installed "sshpas*" Loaded plugins: langpacks, ulninfo Installed Packages sshpass.x86_64 1.06-1.el7 @epel |
Remove packages follow below steps
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
[root@db2 ~]# yum remove sshpass Loaded plugins: langpacks, ulninfo Resolving Dependencies There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help). --> Running transaction check ---> Package sshpass.x86_64 0:1.06-1.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Removing: sshpass x86_64 1.06-1.el7 @epel 38 k Transaction Summary ======================================================================================================================================================================== Remove 1 Package Installed size: 38 k Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : sshpass-1.06-1.el7.x86_64 1/1 Verifying : sshpass-1.06-1.el7.x86_64 1/1 Removed: sshpass.x86_64 0:1.06-1.el7 Complete! |
Check Installed package
1 2 3 |
[root@db2 ~]# yum list installed "sshpas*" Loaded plugins: langpacks, ulninfo Error: No matching Packages to list |
Thank you for giving your valuable time to read the above information.
Follow us on
Website : www.ktexperts.com
Facebook Page : KTexperts
Linkedin Page : KT EXPERTS
Follow Me
Ramesh’s Linkedin : Atul Chandge