11-29-2006
Thanks a lot Srikanthus2002. I did as you mentioned and it's working fine when I try to FTP files in a directory "ftp`date '+%Y%m%d'`" on local server. But, when I try to ftp the same files to one more directory "ftp_verify`date '+%Y%m%d'`" on the local server using 'lcd' command, it do not copy anything there. Actually, to check wether files are FTP'ed correctly on local server, I need to use a verification logic in my script. And to do that I copy files from remote server in 2 different directories on local server and then compare them using 'diff' command in the script. Then after verification I delete the verification directory "ftp_verify`date '+%Y%m%d'`". Can you please explain, why it's not copying files in "ftp_verify`date '+%Y%m%d'`" directory? My scripts is like:
#!/bin/ksh
HOME1=/home/sri
echo " 1"
cd /home
mkdir ftp`date '+%Y%m%d'`
mkdir ftp_verify`date '+%Y%m%d'`
cd ftp`date '+%Y%m%d'`
ftp -n server_ip << END_INPUT > /tmp/ftp_files.log 2>&1
user username password
cd $HOME1
prompt
mget *.txt # copies files correctly
lcd /tmp/ftp_verify`date '+%Y%m%d'`
mget *.txt # Do not copy anything
bye
END_INPUT
cd /home
diff -w ftp`date '+%Y%m%d'` ftp_verify`date '+%Y%m%d'` > /dev/null
if [ $? -ne 0 ]
then
echo "Error: Files are not successfully FTP'd"
mailx -r
user@vrfai030.private.annonymous.com -s \'"Files FTP failed'"
user@annonymous.com < /tmp/ftp_fail.msg
exit 1
rm -r ftp_verify`date '+%Y%m%d'`
fi
exit 0
10 More Discussions You Might Find Interesting
1. IP Networking
Greetings to all.
My new firewall is giving me one hell of a problem.
I'm running iptables and masquerading my intranet
thru NAT. But here is the problem. Whenever I try
to FTP to a server outside of my lan I get a 500
illegal port error.
I've come to the conclusion that NAT is... (2 Replies)
Discussion started by: phrater
2 Replies
2. Shell Programming and Scripting
Hi,
I have created the following FTP script, which transfers daily “.txt” files from remote server in to a timestamped folder on local server. Once all files are FTP'ed, it then deletes files from remote server. When files are FTP'ed, I get a mail messege like, “Files are successfully transfered”,... (1 Reply)
Discussion started by: berlin_germany
1 Replies
3. UNIX for Advanced & Expert Users
Hi,
I am having unix script that passes argument value to script. The script finds the file and keeps it in a directory.
I need to ftp this file to another server. Please guide me how to acieve this.
I am able to connect to ftp server but i am not able to use the unix argument in the ftp... (0 Replies)
Discussion started by: pyaranoid
0 Replies
4. Shell Programming and Scripting
Hi,
I want to compare the size of the files in my local machine before ftp ing it and the size of the file in the remote machine i.e after ftping . SO that the ftp is successful . (3 Replies)
Discussion started by: dineshr85
3 Replies
5. UNIX for Dummies Questions & Answers
Hi All,
I am new to this site, I have a requirement where in i have to FTP a file from mainframe to Unix box.
The catch here is there are few Spanish characters like N with tilde(~) and a with ` etc., all other characters are coming fine but those mentioned above are not coming in a proper... (1 Reply)
Discussion started by: harikiranr
1 Replies
6. Shell Programming and Scripting
I have a file that is 20 - 80+ MB in size that is a certain type of log file.
It logs one of our processes and this process is multi-threaded. Therefore the log file is kind of a mess. Here's an example:
The logfile looks like: "DATE TIME - THREAD ID - Details", and a new file is created... (4 Replies)
Discussion started by: elinenbe
4 Replies
7. Shell Programming and Scripting
I have multiple files that starts as TRADE_LOG spread across multiple folders in the given structure..
./dir1/1/TRADE_LOG*.gz
./dir2/10/TRADE_LOG*.gz
./dir11/12/TRADE_LOG*.gz
./dir12/13/TRADE_LOG*.gz
when I do ftp uisng mput from the "." dir I am getting the below given error
mput... (1 Reply)
Discussion started by: prasperl
1 Replies
8. Shell Programming and Scripting
Hi,
I need to have a shell script that FTP's a zipped file from a particular location.
I have some path and inside that path i will have folders like x_timestamp and inside x_timestamp there may many folders based upon events like y_111,y_222,y_333.Inside each event there will be another... (3 Replies)
Discussion started by: weknowd
3 Replies
9. Shell Programming and Scripting
unix shell script (2 Replies)
Discussion started by: giridhar276
2 Replies
10. Solaris
I need to transfer files from a Windows server to the Unix server and have to run some shell script on it to get the required output.
Is it possible to transfer files from Windows server to unix server through any shell script?
If so can you please help me with the details.
Thanks in... (8 Replies)
Discussion started by: ssk250
8 Replies
FTP_PUT(3) 1 FTP_PUT(3)
ftp_put - Uploads a file to the FTP server
SYNOPSIS
bool ftp_put (resource $ftp_stream, string $remote_file, string $local_file, int $mode, [int $startpos])
DESCRIPTION
ftp_put(3) stores a local file on the FTP server.
PARAMETERS
o $ftp_stream
- The link identifier of the FTP connection.
o $remote_file
- The remote file path.
o $local_file
- The local file path.
o $mode
- The transfer mode. Must be either FTP_ASCII or FTP_BINARY.
o $startpos
-The position in the remote file to start uploading to.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
ftp_put(3) example
<?php
$file = 'somefile.txt';
$remote_file = 'readme.txt';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "successfully uploaded $file
";
} else {
echo "There was a problem while uploading $file
";
}
// close the connection
ftp_close($conn_id);
?>
SEE ALSO
ftp_pasv(3), ftp_fput(3), ftp_nb_fput(3), ftp_nb_put(3).
PHP Documentation Group FTP_PUT(3)