Getting script to run after ftp command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting script to run after ftp command
# 1  
Old 03-29-2011
Getting script to run after ftp command

Hi

I, essentially have two parts in my script. The first ftp's to server S10 and retrieves a batch of files. The second part does the crunching and arranging, They both work independently but when run all in sam script I cannoy get 2nd part to run, i.e. the cat, cut & sed. I think it may be something to do with EOT but after 4 hours trying to get it working I'll pass it around in here first

Code:
more event_S10.sh
#!/usr/bin/sh

#set -x


cd /home/it/capopt/APNRD/S10/er_data
ftp -ni <<EOT
open "$1"
user xxxxx yyyyy
cd /logs/er_data_log/ready
mget *er_data*
bye
#EOT
    timestamp1=`gdate -d today  +%Y%m%d%H%M`
    timestamp2=`gdate -d today  +%Y_%m_%d_%H_%M`
    cat /home/it/capopt/APNRD/S10/er_data/er_data* > $timestamp1
    cut -d " " -f1,2,30 $timestamp1 | sed '/^$/d' > $timestamp2
    rm $timestamp1
    rm er_data*
#EOT
#kill $!
#exit 0

# 2  
Old 03-29-2011
Remove the # from in front of EOT. The EOT must be the first thing in the line or it won't actually end the here-document.
# 3  
Old 03-29-2011
Hi Corona, has no affect unfortunately
# 4  
Old 03-29-2011
Can you show us the two scripts which work along with sample commands used to invoke those scripts?


As there are two "#EOT" lines in your script, we mean the first one.
cd /home/it/capopt/APNRD/S10/er_data
Code:
ftp -ni <<EOT
open "$1"
user xxxxx yyyyy
cd /logs/er_data_log/ready
mget *er_data*
bye
EOT

This User Gave Thanks to methyl For This Post:
# 5  
Old 03-29-2011
Hi Methyl

When I run
Code:
     timestamp1=`gdate -d today  +%Y%m%d%H%M`
    timestamp2=`gdate -d today  +%Y_%m_%d_%H_%M`
    cat /home/it/capopt/APNRD/S10/er_data/er_data* > $timestamp1
    cut -d " " -f1,2,30 $timestamp1 | sed '/^$/d' > $timestamp2
    rm $timestamp1
    rm er_data*

it runs perfectly fine

When I run
Code:
cd /home/it/capopt/APNRD/S10/er_data
ftp -ni <<EOT
open "$1"
user hearne_r Dubliner1
cd /logs/er_data_log/ready
mget *er_data*
bye

it also works fine


however when combined as
Code:
more event_S10.sh
#!/usr/bin/sh

#set -x


cd /home/it/capopt/APNRD/S10/er_data
ftp -ni <<EOT
open "$1"
user hearne_r Dubliner1
cd /logs/er_data_log/ready
mget *er_data*
bye
EOT

    timestamp1=`gdate -d today  +%Y%m%d%H%M`
    timestamp2=`gdate -d today  +%Y_%m_%d_%H_%M`
    cat /home/it/capopt/APNRD/S10/er_data/er_data* > $timestamp1
    cut -d " " -f1,2,30 $timestamp1 | sed '/^$/d' > $timestamp2
    rm $timestamp1
    rm er_data*
#EOT
#kill $!
#exit 0

it only does the ftp bit and retreves the files. It does not parse and aggregate as per teh cat, cut and sed commands
# 6  
Old 03-29-2011
There's a difference. In the ftp script you do this:
Code:
cd /home/it/capopt/APNRD/S10/er_data

in the other, you don't. You may need to cd back to where you started.
# 7  
Old 03-29-2011
Hi Corona

I do cd back in terme of reffering to dir /home/it/capopt/APNRD/S10/er_data

Code:
     cat /home/it/capopt/APNRD/S10/er_data/er_data* > $timestamp1
    cut -d " " -f1,2,30 $timestamp1 | sed '/^$/d' > $timestamp2

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run script like command

hello i have write a script which can create username + password #!/bin/bash # Script to add a user to Linux system if ; then read -p "Enter username : " username read -s -p "Enter password : " password egrep "^$username" /etc/passwd >/dev/null if ; then... (3 Replies)
Discussion started by: nimafire
3 Replies

2. Shell Programming and Scripting

Script to run command one by one

Hi, I have run a lot of commands one after one, but I can't run them simultaneous. One command has to run and when finished second command has to run etc. Also I would like to save all the outputs created by the commands in a file. The commands can sometimes take hours, so it is also... (10 Replies)
Discussion started by: misterx12345
10 Replies

3. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

4. Shell Programming and Scripting

How to run a shell script on a remote host using ftp

Hi, is there a way I can run a shell script through ftp on a remote host? The remote host doesn't have ssh running so I can't use ssh. (7 Replies)
Discussion started by: mrskittles99
7 Replies

5. Shell Programming and Scripting

How to run a script when i'm using FTP???

I have a script which i wanted to run after doing a ftp to the destination server?? How can i do do that??? (9 Replies)
Discussion started by: nikhil jain
9 Replies

6. Shell Programming and Scripting

script will not run cp command

Hi, Not sure what the issue is here, but when i run the script. A simple copy command, it does not find the cp command ? See scrpt below : #!/bin/sh set -x ############################################# # Backup Processes #... (4 Replies)
Discussion started by: venhart
4 Replies

7. Windows & DOS: Issues & Discussions

to run shell script using FTP

Hi All, From FTP prompt, How to run Unix Shell scripts? Thanks in Advance, (1 Reply)
Discussion started by: HemaV
1 Replies

8. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

9. Shell Programming and Scripting

FTP run from shell script gives slow transfer rates

Hey everybody, this is my first post so be gentle. I have two Sun 5220's running Solaris 10 that are directly connected with a cross-over cable at Gig. One of these boxes is my production Oracle server which generates a 50GB dump file every evening at 10:50. The other Solaris is a devolopment... (8 Replies)
Discussion started by: Countificus
8 Replies

10. UNIX for Advanced & Expert Users

script to be run after every FTP transfer

Hello everyone, we are running VSFtpd as FTP Server on Redhat AS 5. I would like to have a script to be run immediately after every FTP transfer. Is is possible (or with any other FTP Server?). I thought of writing a script to monitor if FTP transfer happening and run the required-script... (2 Replies)
Discussion started by: prvnrk
2 Replies
Login or Register to Ask a Question