Execution problem with the FTP shellscript


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execution problem with the FTP shellscript
# 1  
Old 03-28-2013
Execution problem with the FTP shellscript

Hi Friends

I am new to the shell script and i have a script which will connect to server enviornment which will read a file and will FTP to an another server location. But while executing this script FTP transfer is not occuring. But when I enter in FTP mode I am able to transfer the file from one server to another.

Script is

Code:
 
#!/bin/sh
FILE_NAME="/user/sba-appl/productie/sscr/ramu/dd.DAT"
HOST='130.144.240.108'
USER='user name'
PASSWD='password'
ftp -nv <<EOF
open $HOST
user $USER $PASSWD
cd /user/sba-appl/test/sscr/ramu
put $FILE_NAME
EOF

The error which I am getting is 553. The problem is I cant change the chmod permission of the target server as it is an production server. the root directory user doesnt have a write permission. But while using FTP mode I am able to write the the file but through script I am getting 553 error.Can anybody tell me how to solve this problem.Whether I can use symbolic links??. But If i am able to transfer the file using th FTP mode why it is not working with the script??
# 2  
Old 03-28-2013
This is what I found

553 - Requested action not taken. File name not allowed. ---> Change the file name or delete spaces/special characters in the file name
# 3  
Old 03-28-2013
This may be an issue if your $USER actually contains a space. I would be very suprised, but it does look okay otherwise at first glance. When you put the file, I'm assuming that the full path of your file name exists below /usr/sba-appl/test/sscr/ramu too. If not, and that's where you want to put it, try splitting it up.

Perhaps I would move the $HOST to the ftp line and put some tracing in:-
Code:
#!/bin/ksh

FILE_NAME="/user/sba-appl/productie/sscr/ramu/dd.DAT"
HOST='130.144.240.108'
USER='user name'
PASSWD='password'

sourcedir=`dirname $FILE_NAME`
filename=`basename $FILE_NAME`

cd $sourcedir

ftp -nv $HOST <<EOF
user $USER $PASSWORD
status
pwd
cd /usr/sba-appl/test/sscr/ramu
pwd
dir $filename
put $filename
dir_$filename
status
EOF

What output do you get?



Robin
This User Gave Thanks to rbatte1 For This Post:
# 4  
Old 03-29-2013
Hi Robin

Thank you very much now it is working, now I am able to see the File. But I have one more doubt . Whether can i Avoid the password prompt which is coming. If I have given the username and password as static why it is again Prompting for the password.When i checked I understand that we have to edit .netrc file but I cant acces this file in my server. Whether any other metod is there for this. This is not important but for perfection I am asking this. Thanks again for your help

Last edited by Kannannair; 03-29-2013 at 02:13 AM..
# 5  
Old 03-29-2013
I see there is a typo in the variable that you are using inside the ftp client program!

You defined the variable PASSWD initially, but later you are using variable PASSWORD which is undefined:
Code:
PASSWD='password'

sourcedir=`dirname $FILE_NAME`
filename=`basename $FILE_NAME`

cd $sourcedir

ftp -nv $HOST <<EOF
user $USER $PASSWORD

By the way if this approach still does not work, use ftp client program command quote to send username and password to ftp server:
Code:
ftp -n $HOST <<EOF
quote USER $USER
quote PASS $PASSWD
put $filename
EOF

This User Gave Thanks to Yoda For This Post:
# 6  
Old 04-02-2013
I am a fool for such an elementary error as using the wrong variable name.

My apologies.


Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Simple Shellscript for uploading files to a specific folder on a ftp-server?

hi! Iam using my D-link DNS-320 (NAS) with fun_plug installed (a unix client) I am currently using cron to run a shellscript running a java-application that creates a couple of txt files. These files needs to be uploaded to a specific folder on my webhosts ftp server-account. I need a... (16 Replies)
Discussion started by: Nigge
16 Replies

2. UNIX for Dummies Questions & Answers

Execution problem

How to search a pattern from multiple files... i used the command suppose the pattern name is xxx grep xxx (file1-o- file2-o- file3) Thanks in advance (4 Replies)
Discussion started by: ksakil
4 Replies

3. Shell Programming and Scripting

Execution problem

Hi, I have been trying to run a simple script CONFIG_FILE="/jay/check" . . . for i in `cat $CONFIG_FILE` do loc=`echo $i | cut -d "|" -f2` var=$(find $loc -mtime -1|wc -l) if then echo $loc has files older than 1 day fi done . . . (2 Replies)
Discussion started by: jayii
2 Replies

4. UNIX for Dummies Questions & Answers

execution problem

HI I am trying to check the status of port using command /code: netstat -an | grep port /Output: *.2009 *.* 0 0 65535 0 LISTEN what i am trying to do is i want to grep only status Wether the port is established/listen if so show ok else... (1 Reply)
Discussion started by: esumiba
1 Replies

5. UNIX for Dummies Questions & Answers

execution problem

Hi I am automating my few commands out of which one command is tail -f running.logs when i run this command it does not automatically exit and show prompt (#) what would i do so that it will exit out automatically after few seconds and move to the next command without using ... (4 Replies)
Discussion started by: esumiba
4 Replies

6. UNIX for Dummies Questions & Answers

execution problem

Hi i am using expect module and trying to login using following code. ssh 127.0.0.1 expect "word:" send "$password \n" kindly let me know the login script using expect module (1 Reply)
Discussion started by: esumiba
1 Replies

7. Shell Programming and Scripting

sed Problem in Shellscript

Hi, i have a problem with sed i want to substitude a / to ",""," in the following pattern: number/number so if u have a file which contains -> "Streetname 9/8/6" it shouldn't substitude anything, only if it is "Streetname 9/6" to "Streetname 9","","6". Maybe you can help me, i try so many... (5 Replies)
Discussion started by: urukai
5 Replies

8. UNIX for Advanced & Expert Users

shellscript problem

hI, Pls consider the following shell script #!/bin/csh -f sqlplus tkyte/tkyte <<"EOF" > tmp.csh set serveroutput on declare a number:=5; begin dbms_output.put_line( 'a:='||a ); end; / spool off "EOF" The above script does the followin 1)it connects... (1 Reply)
Discussion started by: ravi raj kumar
1 Replies

9. UNIX for Dummies Questions & Answers

korn shellscript execution context - exit statement

Hi all, Could someone please explain to me the shell invocation process when running a script. How do I stop the shell from logging out when it reaches an exit statement in the script? if ; then echo 'Failed to copy ${FILE}.fmx to ${J2_HOME}/dev/rsc' ... (3 Replies)
Discussion started by: richgi
3 Replies

10. UNIX for Advanced & Expert Users

ftp in Shellscript

Can I do something like this from a shellscript ?: ftp 12.34.56.78 <<! username password put a.c bye ! It does not go through as the login fails. Is there any alternative to do the above requirement? Thanks in advance. Gowrish (3 Replies)
Discussion started by: ggowrish
3 Replies
Login or Register to Ask a Question