FTP in shell script   Independent houses near kukatpally | Apartments in Pragathi Nagar | AndhraVaani.com | Log Out | Topics | Search
Register | Edit Profile

Bewarse TalkArchivesCine Talk - Reviews, Gossips, Insider Info etc.Archive through October 25, 2005 � FTP in shell script Previous Next

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

Dilligaf
Kurra Bewarse
Username: Dilligaf

Post Number: 579
Registered: 06-2005
Posted From: 72.44.13.253
Posted on Monday, October 24, 2005 - 6:34 pm:   Edit PostDelete PostView Post/Check IP

nayakuda mayya a small advice is instead of echo $OTPUT > $ERR_FILE use something like echo $OTPUT > $ERR_FILE 1>&2 so that it captures both err and the output
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 623
Registered: 05-2005
Posted From: 129.188.33.222
Posted on Monday, October 24, 2005 - 6:00 pm:   Edit PostDelete PostView Post/Check IP

ok mama.. thanks...

1. "File not found" lati error msgs kosam check chesi mail cheyyatam
2. all error codes check chesi... error code vunte user ki log file attachment laga pampatam (anni status vundiddi).. pls check in attached log file for error ani
3. target lo file slist chesi size compare cheyyatam (
4. all successful codes check cheyyatam(150, 226)...

aa file size ela check cheyyali.. inko 3 hrs paduthundikada
Top of pagePrevious messageNext messageBottom of page Link to this message

Dilligaf
Kurra Bewarse
Username: Dilligaf

Post Number: 578
Registered: 06-2005
Posted From: 72.44.13.253
Posted on Monday, October 24, 2005 - 5:55 pm:   Edit PostDelete PostView Post/Check IP

so wut we are doing is just grep'n the file not command
Top of pagePrevious messageNext messageBottom of page Link to this message

Dilligaf
Kurra Bewarse
Username: Dilligaf

Post Number: 577
Registered: 06-2005
Posted From: 72.44.13.253
Posted on Monday, October 24, 2005 - 5:54 pm:   Edit PostDelete PostView Post/Check IP

nayakudi mayya let me ask something neeku file ni put chestunte emi error ravochu..file not find 99% thinking that you have able to connect to ftp client "File not found"

OTPUT=`ftp -n -v $HOST <<END_HERE
user $USER $PASSWD
cd /ftpdata/common/
lcd /v1/org/bs/users/ddts/local/admin/gems_dw/
put $FILE1
put $FILE2
rename $FILE1 sch_scog_parents.dat
rename $FILE2 sch_scog_children.dat
END_HERE`
echo $OTPUT > $ERR_FILE

ERR_MSG=`grep -E -i 'Not connected|421|425|426|450|451|452|500|501|502|503| 504|5
22|530|532|550|552|553|554|555' $ERR_FILE`

##Grep out for the "put command error"
ERR_MSG1=`grep -i 'File not found' $ERR_FILE`

if (grep -E -i 'Not connected|421|425|426|450|451|452|500|501|502|503| 504|522|53
0|532|550|551|552|553|554|555' $ERR_FILE) ; then

echo "Failed"
echo "$ERR_MSG"|mail $USER_ID
else
echo "Success"
fi

if (grep -i 'File not found' $ERR_FILE) ; then
echo "$ERR_MSG1|mail $USER_ID
else
fi
Top of pagePrevious messageNext messageBottom of page Link to this message

Infinity
Vooriki Bewarse
Username: Infinity

Post Number: 4908
Registered: 04-2005
Posted From: 192.127.94.7
Posted on Monday, October 24, 2005 - 5:50 pm:   Edit PostDelete PostView Post/Check IP

there is no direct method to check whether the file has been ftped successfully.

first grep for 150 that says the transfer initiated and again grep for 226 that says transfer complete. more accurate way is to "list the file in the target directory and compare the size"
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 622
Registered: 05-2005
Posted From: 129.188.33.222
Posted on Monday, October 24, 2005 - 5:42 pm:   Edit PostDelete PostView Post/Check IP

correct dilligaf mama...
ftp tharuvatha shell commands work avvatla...
edo site lo
! exit use chesi shell run cheya vachhu ani vundi.. run chesa work avvatla
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 621
Registered: 05-2005
Posted From: 129.188.33.222
Posted on Monday, October 24, 2005 - 5:41 pm:   Edit PostDelete PostView Post/Check IP

dilligaf mama, parameters annitini hard code chesa mama script lone... so command line lo nunchi pass cheyyatam la nenu...
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 620
Registered: 05-2005
Posted From: 129.188.33.222
Posted on Monday, October 24, 2005 - 5:40 pm:   Edit PostDelete PostView Post/Check IP

Infinity mama... thanks..

FTP success or fail ani ela check chestharu... whatever codes start with eithe 4 or 5 means error right... anduke anni 4, 5 tho start ayye vati kosam output lo checkj chesthunna... edaina vunte aa okka line ne return cheyyali... kani output natha oke line li vundi .. mohtm return chsthundi GREP command..
Top of pagePrevious messageNext messageBottom of page Link to this message

Dilligaf
Kurra Bewarse
Username: Dilligaf

Post Number: 576
Registered: 06-2005
Posted From: 72.44.13.253
Posted on Monday, October 24, 2005 - 5:39 pm:   Edit PostDelete PostView Post/Check IP

andu kosam ... \n character ni each ftp command tharuvatha insert cheddam an chusthunna.. allow cheyyatmal ftp command tharuvatha...

idhi actual ga work avvadu mayya coz it treats everything as a ftp command
Top of pagePrevious messageNext messageBottom of page Link to this message

Infinity
Vooriki Bewarse
Username: Infinity

Post Number: 4906
Registered: 04-2005
Posted From: 192.127.94.7
Posted on Monday, October 24, 2005 - 5:36 pm:   Edit PostDelete PostView Post/Check IP

to create a static ftp script.. echo all the ftp commands after replacing them with the command line parameters in to a new FTP.sh and submit this FTP.sh to ftp server.
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 619
Registered: 05-2005
Posted From: 129.188.33.222
Posted on Monday, October 24, 2005 - 5:36 pm:   Edit PostDelete PostView Post/Check IP

first ila try chesa.. log file loki direct cheyyataniki

ftp -n -v $HOST <<END_HERE > a.log
user $USER $PASSWD >> a.log
cd /ftpdata/common/ >> a.log
lcd /v1/org/bs/users/ddts/local/admin/gems_dw/
put $FILE1 >> a.log
put $FILE2 >> a.log
rename $FILE1 sch_scog_parents.dat >> a.log
rename $FILE2 sch_scog_children.dat >> a.log
END_HERE

kani ala accept cheyyatmala.. so oka variable loki thesukunna output of all FTP commands
Top of pagePrevious messageNext messageBottom of page Link to this message

Infinity
Vooriki Bewarse
Username: Infinity

Post Number: 4904
Registered: 04-2005
Posted From: 192.127.94.7
Posted on Monday, October 24, 2005 - 5:35 pm:   Edit PostDelete PostView Post/Check IP

mama.. damn it.. 3 yrs back chesanu.. command gurthuku raavatam ledu. :-(

offshore ID lock chesi vundi.. aaa script chooddamante..

google cheste ee link inchindi.. check this if it is useful

http://www.columbia.edu/kermit/ftpscripts.html


I remember few things: we used to store all the commands in a file and submit it at the command prompt. Here in this files names also static.. no parameters.

for the parameter type script I feel you should take parameters into a shell script.. create a the actual ftp script and submit that ftp script to ftp client in silent mode. I did this when a program do not work with command line parameters.. :-)

hope these inputs would give some clues to you.
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 618
Registered: 05-2005
Posted From: 129.188.33.222
Posted on Monday, October 24, 2005 - 5:33 pm:   Edit PostDelete PostView Post/Check IP

andu kosam ... \n character ni each ftp command tharuvatha insert cheddam an chusthunna.. allow cheyyatmal ftp command tharuvatha...

edo try chesa ! and exit ani... work kavatla
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 617
Registered: 05-2005
Posted From: 129.188.33.222
Posted on Monday, October 24, 2005 - 5:32 pm:   Edit PostDelete PostView Post/Check IP

kshell anukunta mama... paina ksh ani vundi. file extension mathram .sh ne
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 616
Registered: 05-2005
Posted From: 129.188.33.222
Posted on Monday, October 24, 2005 - 5:31 pm:   Edit PostDelete PostView Post/Check IP

yemo mama.... oke machine ki connect ayyi vunna.. WTS lo vunna mari
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 615
Registered: 05-2005
Posted From: 129.188.33.222
Posted on Monday, October 24, 2005 - 5:31 pm:   Edit PostDelete PostView Post/Check IP

OTPUT=`ftp -n -v $HOST <<END_HERE
user $USER $PASSWD
cd /ftpdata/common/
lcd /v1/org/bs/users/ddts/local/admin/gems_dw/
put $FILE1
put $FILE2
rename $FILE1 sch_scog_parents.dat
rename $FILE2 sch_scog_children.dat
END_HERE`
echo $OTPUT > $ERR_FILE

ERR_MSG=`grep -E -i 'Not connected|421|425|426|450|451|452|500|501|502|503| 504|5
22|530|532|550|552|553|554|555' $ERR_FILE`

if (grep -E -i 'Not connected|421|425|426|450|451|452|500|501|502|503| 504|522|53
0|532|550|551|552|553|554|555' $ERR_FILE) ; then

echo "Failed"
echo "$ERR_MSG"|mail $USER_ID
else
echo "Success"
fi

paina script motham work avuthundi...

naa rqmt vachhi.. suppose PUT FILE fail ayithey..i shouldbe able to mail only yhat error to support guy. But, currently the output gets the status of all ftp commands in one line. so when there is error due to one command... status of all commands is going as mail
Top of pagePrevious messageNext messageBottom of page Link to this message

Durga
Desanike Pedda Bewarse
Username: Durga

Post Number: 9376
Registered: 03-2004
Posted From: 12.144.110.131
Posted on Monday, October 24, 2005 - 5:30 pm:   Edit PostDelete PostView Post/Check IP

endi nayakudu mamaoi..ganta lonne rendu ip tho postingu..
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 614
Registered: 05-2005
Posted From: 129.188.33.222
Posted on Monday, October 24, 2005 - 5:28 pm:   Edit PostDelete PostView Post/Check IP

END_HERE tharuvatha end avuthundi chudu mama...

END_HERE`.

aa FTP output ni log file ki direct cheyyathi kavatam laaa... so variable lo store chesthunnaaa
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 613
Registered: 05-2005
Posted From: 129.188.33.222
Posted on Monday, October 24, 2005 - 5:27 pm:   Edit PostDelete PostView Post/Check IP

mama work avuthundi... script...
Top of pagePrevious messageNext messageBottom of page Link to this message

Dilligaf
Kurra Bewarse
Username: Dilligaf

Post Number: 575
Registered: 06-2005
Posted From: 72.44.13.253
Posted on Monday, October 24, 2005 - 5:15 pm:   Edit PostDelete PostView Post/Check IP

also ee script deeni lo rastunaav I mean which shell..your tick here started but didn't end in this line OTPUT=`ftp -n -v $HOST <<END_HERE
Top of pagePrevious messageNext messageBottom of page Link to this message

Dilligaf
Kurra Bewarse
Username: Dilligaf

Post Number: 574
Registered: 06-2005
Posted From: 72.44.13.253
Posted on Monday, October 24, 2005 - 5:13 pm:   Edit PostDelete PostView Post/Check IP

nayakudu mama..asaalu ftp allowed ah server ki..make sure you first test it manually..koni sarlu you can restrict users from using ftp by using /etc/ftpusers..naaku adhi connect avuthundi manual ga ani cheppu next step ki eldaam
Top of pagePrevious messageNext messageBottom of page Link to this message

Nayakudu
Kurra Bewarse
Username: Nayakudu

Post Number: 612
Registered: 05-2005
Posted From: 136.182.2.222
Posted on Monday, October 24, 2005 - 4:27 pm:   Edit PostDelete PostView Post/Check IP

mama evaraina FTP chesara shell nunchi...

naa rqmt

FTP output ni seperate lines lo ravalai... FTP lo shell commands work avvatla... evariana chesthey konchem cheppandi

OTPUT=`ftp -n -v $HOST <<END_HERE
user $USER $PASSWD
cd /ftpdata/common/
put $FILE1
put $FILE2
rename $FILE1 aa.dat
rename $FILE2 bb.dat
END_HERE`

aa FTP commands anni status code return chesthunnayi.. kani oke line lo vasthundi output... aa output ni search chesi.. ye command fail ayyindo error code chusi nenu mail cheyyali support person ki... ippudu fail ayithey motham status velthundi mail lo...