FTP a file to a remote Server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP a file to a remote Server
# 1  
Old 02-23-2006
FTP a file to a remote Server

Dear all,
I am trying to push a data file to a remote Server. I am taking date variable from the database.
The file I want to push looks like this in /tmp

hostname.export.beforedate.dmp.gz

for reading the date from the database i have a file get_date.sql which contains

select before_bis_date from dates;
commit;
exit

and the script i use for the remote ftp push is as below

#!/bin/sh
HOST=10.0.1.20
USER='oracle'
PASSWD='oracle'
brn=`hostname`
today=`/oracle/bin/sqlplus -S ims/imsadm@$ORACLE_SID @get_dt.sql`
count=1
for mydate in $today
do
if [ $count = "3" ]
then
bisdate=$mydate
fi
count=$[$count+1]
done

cd /tmp

echo ---------------------------------------------------------------------------
echo The branch $brn FTP started....
ftp -n $HOST <<END_SCRIPT
quote user $USER
quote pass $PASSWD
cd /tmp/
bin
put $brn.export.$bisdate.preEOD.dmp.gz
bye
END_SCRIPT
echo The branch $brn FTP finished !
echo ---------------------------------------------------------------------------
exit 0

but i am getting error

this script works fine when i run it manuall but if i try to run it using cron entry i get the following error

From oracle Thu Feb 23 18:48:00 2006
Return-Path: <oracle@mig2>
Received: (from oracle@localhost)
by mig2 (8.11.6/8.11.6) id k1ND30v14724
for oracle; Thu, 23 Feb 2006 18:48:00 +0545
Date: Thu, 23 Feb 2006 18:48:00 +0545
Message-Id: <200602231303.k1ND30v14724@mig2>
From: root@mig2 (Cron Daemon)
To: oracle@mig2
Subject: Cron <oracle@mig2> /oracle/scripts/pulldump_scripts/pull_dump.sh
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/oracle>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=oracle>

---------------------------------------------------------------------------
The branch mig2 FTP started....
local: mig2.ims.internal.preEOD.dmp.gz: No such file or directory
The branch mig2 FTP finished !
---------------------------------------------------------------------------
CAN ANY ONE HELP ME!!!!!!!!!! its urgent
# 2  
Old 02-23-2006
Your code does not match the error message.
Code:
put $brn.export.$bisdate.preEOD.dmp.gz

Quote:
local: mig2.ims.internal.preEOD.dmp.gz: No such file or directory
# 3  
Old 02-26-2006
FTP to a file to the remote server

Quote:
Originally Posted by Ygor
Your code does not match the error message.
Code:
put $brn.export.$bisdate.preEOD.dmp.gz


AS $brn=hostname
export=export
$bisdate=internal(this is where the error is it will give internal in ftp during corn rather than taking the bisdate variable fron the above)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FTP a File to a Remote Server

Hi, I'm fairly new to Linux and need help with a script to ftp a .csv file to a remote server. I can ftp the .csv file manually from my server to the remote server in the "/" location. When I execute the script I receive the following message Could not create file. Here's what I have for... (5 Replies)
Discussion started by: Computergal2104
5 Replies

2. Shell Programming and Scripting

FTP using script not working (for transfering file from a remote unix server to windows PC.)

hi, Im using the following code for FTP #!/usr/bin/ksh ftp -v -n "10.29.45.11" << cmd user "mahesva" "mahesva123" get rtl.tar quit cmd Below is the log when i run the above code ********************************** Connected to 10.29.45.11. 220 (vsFTPd 2.0.1) 530 Please login with USER... (20 Replies)
Discussion started by: dll_fpga
20 Replies

3. Shell Programming and Scripting

How to FTP the latest file, based on date, from a remote server through a shell script?

How to FTP the latest file, based on date, from a remote server through a shell script? I have four files to be FTP'ed from remote server. They are of the following format. build1_runtime_mmddyyyy.txt build2_runtime_mmddyyyy.txt build3_runtime_mmddyyyy.txt buifile_count_mmddyyyy.txt ... (9 Replies)
Discussion started by: imran_affu
9 Replies

4. Shell Programming and Scripting

preserving the timestamp of a file when copied from remote server to local server using ftp

Hi, I need to copy few files from remote server to local server. I write a shell script to connect to the remote server using ftp and go to that path. Now i need to copy those files in the remote directory to my local server with the timestamp of all those files shouldnt be changed. ... (5 Replies)
Discussion started by: arunkumarmc
5 Replies

5. UNIX for Dummies Questions & Answers

To ftp file on a remote server

I want to send some files in .gz format from my desktop to a remote server. What will be the procedure for that thanks (5 Replies)
Discussion started by: supercops
5 Replies

6. Shell Programming and Scripting

Contantly check for file at the remote server and ftp when avaliable

Hello, I used the search engine but could not find the solution I am looking for. Probably its simple but I do not know the solution. My requirement is I ftp files every day in the morning from the remote server to the local machine. Now if the files are not there at the time I schedule the ftp... (2 Replies)
Discussion started by: kiran_418
2 Replies

7. UNIX for Dummies Questions & Answers

Remote Access to FTP server not working

I am trying to setup an FTP server in a Fedora Core 3 machine through the command line interface and not KDE. I think I am successful in getting the ftp service running, as when I do an ftp 127.0.0.1, I am able to log in using any one the user accounts I have created on this machine and browse... (8 Replies)
Discussion started by: cooljumbo2k8
8 Replies

8. Shell Programming and Scripting

rename files in remote server via ftp

Hi All, I want to rename set of files in the remote server which iam unable to do . i can rename only one file at a time . for example ftp $REMOTESERVER { rename $NAME1 $NAME2 } is working whereas ftp $REMOTESERVER { rename $NAME1*.dat $NAME2*.data } is not working ...... (4 Replies)
Discussion started by: dineshr85
4 Replies

9. Shell Programming and Scripting

FTP multiple files from remote server to local server

Hi, I am facing a weired problem in my FTP script. I want to transfer multiple files from remote server to local server everyday, using mget * in my script. I also, want to send an email for successful or failed FTP. My script works for file transfer, but it don't send any mail. There is... (2 Replies)
Discussion started by: berlin_germany
2 Replies

10. Shell Programming and Scripting

FTP - Get the file date and time on the remote server

I would like to know if there is a way to get the date and timestamp of the file that is being FTP from the remote server using shell script. Currently the get command from FTP will have current date and timestamp. Tried the earlier suggestion 'HardFeed' but still getting the current date and time... (12 Replies)
Discussion started by: gthokala
12 Replies
Login or Register to Ask a Question