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
- Create user in Solaris network e.g. ftpuser
- Create shell script file which contains set of commands to:
- Get files (those needed to transfer) from local server
- Connect to the destination server (where we need to transfer files) using FTP credentials.
- Execute actual transfer of files from source server to destination server.
- Here is the skeleton of the shell script file. We will see working example of the script later on.
- Here is the example of working shell script i.e. movefiles.sh
- Put this shell script into home folder of solaris user. In our case, the path will be like
- If we want to transfer files over cross-networks on regular intervals, we can set crontab for this.
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:
>