Sometimes it can be a huge pain when needing to transfer files between cross-platforms because things don’t always go smoothly. First you have to set up the shares, then you need to make sure the permissions are correct, and one can’t forget the need to use a file transfer protocol that each of the operating systems support.
Here we will see an example of how to transfer files on cross-platform networks. We will see transfer of files from Solaris network to Windows network.
I have followed the below mentioned steps to achieve the same
Let’s name this file as movefiles.sh
#!/bin/bash
#Connect to windows ftp server
#Declare variables and assign them related values which will be used for remote
#server connection
HOST=> #This is the FTP server’s host or IP address.
USER=> #This is the FTP user that has access to the server.
PASS=> #This is the password for the FTP user.
#Create connection to remote server
ftp -inv $HOST
user $USER $PASS
binary
#Now as you are in remote environment, mention destination folder name where you
#want to transfer desired files
cd />
lcd />
#Copy files from source to destination
mput *.*
bye
EOF
#Optional, if you want to delete source files, once they get copied to desired
#destination network
cd />
rm *.*
#!/bin/bash
# Connect to windows ftp server
HOST=192.168.1.204
USER=ftpuser
PASS=test123
ftp -inv $HOST
user $USER $PASS
binary
# Destination folder on remote network
cd /vrrupload
# Source folder on local network
lcd /export/home/ftpuser/files
mput *.*
bye
EOF
# Delete source files, once they get copied to desired destination network
cd /export/home/ftpuser/files
rm *.*
/home/ftpuser/movefiles.sh
We can achieve it by using “crontab –e “
linux command and setting something like this:
>
> * * * sh /home/ftpuser/movefiles.sh > /home/ftpuser/files-out_`date +%Y-%m-%d_%H:%M%S`.log 2>&1