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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run a script when i'm using FTP???
# 1  
Old 04-03-2012
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???
# 2  
Old 04-03-2012
what is your problem? make ftp?
# 3  
Old 04-03-2012
m able to do ftp, but don't know how to run a script in the destination server???
# 4  
Old 04-03-2012
For running the script in destination server, you can use the ssh

check "passwordless ssh setup" ( in this forum or google )

Code:
 
ssh user@host "/your/script/path/in/remote/server.sh"

# 5  
Old 04-03-2012
thank you itkamaraj Smilie
but i wanted to run the script when m doing the ftp.... Smilie
# 6  
Old 04-03-2012
seems, you want to ftp the file to remote server and your script will use the ftp'ed file ?

then, do with

Code:
 
scp file.txt user@host:/path/of/remote/machine/
ssh user@host "/your/script/path/in/remote/server.sh"

# 7  
Old 04-03-2012
Quote:
Originally Posted by nikhil jain
m able to do ftp, but don't know how to run a script in the destination server???
try this (before change your values[USER AND HOST AND SSH COMMAND])
Code:
# ./justdoit ftpfile
............

Code:
# cat justdoit
#!/bin/bash
FTPUSER=test ; FTPHOST=localhost
RUSR=test ; RHOST=localhost
remove() {
rm -f $HOME/.netrc
}
[ -z "$1" ] && echo "File name is empty" && exit 1
echo -e "\n___FTP PHASE___\n"
read -s -p "Please give your '$FTPUSER''s ftp password ? " passwdx
echo "machine $FTPHOST"  >  $HOME/.netrc
echo "login $FTPUSER"        >> $HOME/.netrc
echo "password $passwdx"     >> $HOME/.netrc
echo "macdef init"          >> $HOME/.netrc
echo "bin"                  >> $HOME/.netrc
echo "put $1"            >> $HOME/.netrc
#echo "bye"                  >> $HOME/.netrc
echo ""                     >> $HOME/.netrc
chmod 600 $HOME/.netrc
ftp -i localhost &>/tmp/ftplogg & ftp_id=$!;wait $ftp_id
grep "Login incorrect" /tmp/ftplogg
if [ $? -eq 0 ] ; then
echo -e "\nYour FTP password is Incorrect!!";remove;exit 1
fi
grep "No such file" /tmp/ftplogg
if [ $? -eq 0 ] ; then
echo -e "\nFTP FileName is invalid!!";remove;exit 1
fi
echo "Your FTP command probably 'SUCCESS'fully finished"
remove
echo -e "\n___SSH PHASE___\n"
ssh -o ConnectTimeout=10 -o NumberOfPasswordPrompts=1 ${RUSR}@$RHOST echo "remove echo and Add your script"
[ $? -ne 0 ] && echo -e "\nSSH 'FAILED' CHECK YOUR PASSWORD OR SSH KEYS on '$RHOST' !!\n\
Be Sure Public Key was correctly placed in 'authorized_keys' in '$RHOST' \n\
\n== Check SSH Permissions ==\n\
=================================
$RHOST/.ssh/ --> 755
$RHOST/.ssh/authorized_keys --> 644
$RHOST/.ssh/id_dsa --> 600
$RHOST/.ssh/id_dsa.pub --> 644
$RHOST/.ssh/id_rsa --> 600
$RHOST/.ssh/id_rsa.pub --> 644
$RHOST/.ssh/known_hosts --> 644
================================= \n"\
  && exit 1
echo -e "\n\"All Operations were SUCCESSFULLY completed\"\n"

regards
ygemici
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. 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

3. Shell Programming and Scripting

how to run an already made script run against a list of ip addresses solaris 8 question

how to run an already developed script run against a list of ip addresses solaris 8 question. the script goes away and check traffic information, for example check_GE-VLANStats-P3 1.1.1.1 and returns the results ok. how do I run this against an ip list? i.e a list of 30 ip addresses (26 Replies)
Discussion started by: llcooljatt
26 Replies

4. 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

5. Shell Programming and Scripting

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... (10 Replies)
Discussion started by: rob171171
10 Replies

6. AIX

My script didn't run every run every minute at cronjob

In my cronjob, I would like to schedule my script.sh to run every minutes. I crontab -e and have in line below but it didn't seems to run at all. * * * * * script.sh When I run it manually, I can run it. Is that anything wrong with the above line? If I change it to something like below,... (4 Replies)
Discussion started by: ngaisteve1
4 Replies

7. 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

8. 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

9. UNIX for Advanced & Expert Users

FTP taking ages to run.

Hi every one, We have HP UX server which normally loaded as avg load of 19-21. NOw when I try and do ftp to this server it takes ages to get the FTP prompt. I have seen this server loaded as max agv load of 35-40 tht time we never had such problems of FTP sessions. Now my new Unix admin... (1 Reply)
Discussion started by: nilesrex
1 Replies
Login or Register to Ask a Question