Some more things I want to clarify (I tried googling too but it got me more confused).
1) - I want to transfer file from location /o2/logs/weblogic/o2prl/ from server blx28ap05.
2) - My shell script is in location /o2/home/n412426 on blx28ap05
3) - I want to transfer file to server blx07ap09 on location /o2/home.
I want to try ftp first (as I am just testing this now) after that I'll try sftp when I'll prepare this for live data.
Okay, well first we should check that /o2/home/n412426 is on your search path:-
echo $PATH
The output will be a list of directories separated by colons. If the above is your home/default directory then it may well be in the list already. You can extend the search list with:-
Code:
export PATH=$PATH:/o2/home/n412426
or
Code:
export PATH=$PATH:$HOME
... if it is your home directory.
Assuming that you have write permission to /o2/home on blx07ap09, then the following should get you going:-
Code:
ftp -n blx07ap09 <<-EOFTP > /tmp/myftp.log
user $userid
$password
cd /o2/home
put $filename
EOFTP
echo "Finished FTP with return code $?"
You may need to adjust this by putting the password to the end of the previous line. The EOFTP must only be indented by tab characters, not spaces. The output will be caught in /tmp/myftp.log
You can change the target filename by appending it to the end of the put statement if you wish.
I hope that this gets you going enough for now. If it doesn't work, could you post back the messages it returns.
I amended the script as you suggested.
But now when I do "./script_name", I only get the following -
Code:
Checking if there are inactive log files on the home directory....
Inactive files are present
Continuing to further check the latest inactive file
Latest inactive file is o2prl-05.log00427
Starting transfer of file o2prl-05.log00427
and then nothing and when I press cntrl+C, it gives output as -
Code:
Finished FTP with return code 0"
The file that is currently to be transferred is -
Code:
-rw-r--r-- 1 o2prladm o2 5634 May 8 16:22 o2prl-05.log00427
Seems like I am making script using my ID (n412426) and the file that needs to be transferred is in o2prladm user.
I've checked and verified that the destination directory has write access to my account n412426.
There is nothing in the log file..it is empty..
I've put quit before EOFTP and now the whole script looks like -
Code:
# Transferring latest inactive log file to another server
echo "Checking if there are inactive log files on the home directory...."
HOME_DIR=/o2/logs/weblogic/o2prl/
HOST=blx19au01
USER=n412426
PASSWD=xxxxxx
if [ `ls ${HOME_DIR}o2prl-05.log0* |wc -l` ];
then
echo "Inactive files are present"
echo "Continuing to further check the latest inactive file"
# Counting the number of inactive files
filename=`ls ${HOME_DIR}o2prl-05.log0* | tail -1`
file=`basename $filename`
echo "Latest inactive file is $file"
# Start file transfer
echo "Starting transfer of file $file"
ftp -n $HOST <<-EOFTP > /o2/home/n412426/myftp.log
user ${USER}
${PASSWD}
cd /o2/home/n412426/
put $file
quit
EOFTP
echo "Finished FTP with return code $?"
else
echo "There are currently no inactive log files on the home directory...."
fi
NOTE : I've changes host to blx19au01 as my ID (n412426) has access to my home directory (/o2/home/n412426).
I would therefore assume that it's waiting for the password to be typed. Try putting it on the same list as the userid:-
Code:
...
...
ftp -n $HOST <<-EOFTP > /o2/home/n412426/myftp.log
user ${USER} ${PASSWD}
cd /o2/home/n412426/
...
...
... and see if that helps.
Robin
No luck still.
Whe I waited for script to complete...after 4-5 misn it gave the following output -
Code:
Checking if there are inactive log files on the home directory....
Inactive files are present
Continuing to further check the latest inactive file
Latest inactive file is o2prl-05.log00427
Starting transfer of file o2prl-05.log00427
ftp: connect: Connection timed out
Finished FTP with return code 0
Hi
Please can you tell me what could be wrong with the following scriptto transfer files from solaris 10 to windows machine:
#!/bin/sh
HOST=<IP>
USER=administrator
PASSWD=xyz123zyx
/usr/bin/ftp -inv <<EOF
connect $HOST
user $USER $PASSWD
cd Documents
binary
mput *.sh
bye
EOF (23 Replies)
Hi.
I want to schedule a job at some directory will several files in it.
But there maybe a situation whereby some of the files at the point of the schedule are still transferring during that time.
So I want to skip those files from being processed.
Two method that come to my mind:
1.... (5 Replies)
Hello to all,
I want to copy from one server to another files of last 24 hours with size between 500MB and 2GB. The code below searches last files in 24 hours.
find . -mtime -1
In order to copy faster I'd like to compress the files before copying them.
How to automate the process of... (8 Replies)
Hi
I have the following script:
#!/bin/sh
set -x
touch -mt 201210040000 /tmp/ref1
touch -mt 201210042359 /tmp/ref2
find /fs1/bscsrtx/BSCS_ix/WORK/LOG -type f \( -newer /tmp/ref1 -a ! -newer /tmp/ref2 \) > file_lst
scp $(< file_lst) root@10.100.48.76:/ano2005/fs1_2015/LOG/
but somehow its... (7 Replies)
Hi All
Please can you help, I´ve wrote the following script on a solaris 10 server to transfer files to a windows machine.
#!/usr/bin/sh
cd /moneta_polled01/download
HOST=10.100.4.72
USER=user1
PASSWD=V7stop
/usr/bin/ftp -v $HOST <<EOF
user $USER $PASSWD
cd tmp
binary
put... (7 Replies)
Hi guys ,
how are you doing?
I am tryng to make a script using cp that i would like to do this:
echo "Enter the name files to tranfer"
then user has to enter via keyboard this kind of output
file1 file 2 file 3 file x
(i mean the number of the files could vary and their name too)... (1 Reply)
Hi,
I am new to scripting, I need to write a script to transfer .TXT files from Server A (ftp) to Server B. Once the files in server B i need to transfer it to server C (sftp). (not transfer of files directly from server A to Server C )
Thanks!
Regards
Sendhil
---------- Post updated at... (3 Replies)
Hi everybody,
I just want to transfer files with FTP (mget and mput). The problem is that I dont want to overwrite any existing files and don't want to transfer them again (e.g. using the rename-function). So I only want to transfer new files with mget and mput.
My first idea was to create... (3 Replies)
I need to write a shell script to transfer files from Unix server to windows machine. This script will be scheduled on scheduler to run at specified intervals
#!/bin/ksh
ftp -n alaska <<End-Of-Session
user sss01 sample
cd /home/sss01
lcd D:/sample
mget *.txt
bye
when I executed the... (15 Replies)
I have written generic script to transfer files from one machine to other machine(By passing the command line arguments like server name, user name ,location of the files, file names etc) but
when i am using sftp, what are the things I have to specify in the code
Is it necessary to specify... (0 Replies)