• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

problem with ftp script

hi...
i have this ftp script that is suppose to transfer files and folders over to a server,
however it seems that this script keep on processing and unable to exit out of
the the ftp loop.

Is there any problem with this script

#!/bin/sh
USER=root
PASSWD=password

cd /home/student/Desktop
# this will get everything under /usr2/u/ls-2000/QjobSpec and place
# it into a folder called rvsi2 which is only created when this
# script is executed
wget -r ftp://${USER}:${PASSWD}@rvsi2/\/usr2/u/ls-2000/QjobSpec
# the data you download will be sit under
# /home/student/this/ysw2f011//home/student/mp3/chinese
# you can move it up by:

cd /home/student/Desktop//QjobSpec
mv QjobSpec /home/student/Desktop
cd /home/student/Desktop

# Remove the files on the remote host.
ftp -n -i rvsi2 <<EOF
user root password
cd /usr2/u/ls-2000/QjobSpec
delete *
binary
quit
EOF
exit

thanks
ps i'm using linux
0
TPoly
Asked:
TPoly
  • 10
  • 9
1 Solution
 
yuzhCommented:
Put a debug statement in your script, make it looks like:

#!/bin/sh
set -x
USER=root
PASSWD=password

cd /home/student/Desktop
# this will get everything under /usr2/u/ls-2000/QjobSpec and place
# it into a folder called rvsi2 which is only created when this
# script is executed
wget -r ftp://${USER}:${PASSWD}@rvsi2/\/usr2/u/ls-2000/QjobSpec
# the data you download will be sit under
# /home/student/this/ysw2f011//home/student/mp3/chinese
# you can move it up by:

cd /home/student/Desktop//QjobSpec
mv QjobSpec /home/student/Desktop
cd /home/student/Desktop

# Remove the files on the remote host.
ftp -in rvsi2 <<EOF
user root password
cd /usr2/u/ls-2000/QjobSpec
delete *
quit
EOF
exit

#End of script

and post the screen output

Warning: don't ftp login as root!, a sniffer can get your root password, consider use
secure shell/ftp instead.
0
 
TPolyAuthor Commented:
if i do not login as root, i cld not ftp into the computer
0
 
TPolyAuthor Commented:
hi yuzh
btw is the secure shell/ftp able to use the same codes?

can debian use that?

thankssss
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
yuzhCommented:
btw is the secure shell/ftp able to use the same codes?

No, you can use "ssh+tar" or scp or sftp to transfer the file accross, or delete files.

can debian use that?
Yes

You need to install secure shell (Openssh) and configure in both server and client.

You can do a search at EE to find information about how to setup ssh, and search
for "ssh without password" to setup ssh login without password.

It is now our weekend, if you still need help next week, I'll come back to your question,
hopefully someone can help you out in the next 2 days. (it need time to set it up).

Have a nice weekend, cheers!
0
 
MysidiaCommented:
Yes...
re: the line

wget -r ftp://${USER}:${PASSWD}@rvsi2/\/usr2/u/ls-2000/QjobSpec

other users logged into the system (if there are any) may be able to see the username and password
with the ps command

so can anyone who is able to read or execute the script

secure shell and rsync or scp  would indeed be much better for this

i.e.
scp -r username@host:/usr2/u/ls-2000/QjobSpec ./
0
 
TPolyAuthor Commented:
++ USER=root
++ PASSWD=password
++ cd /home/student/Desktop
++ wget -r ftp://root:password@rvsi2//usr2/u/ls-2000/QjobSpec
--09:31:13--  ftp://root:*password*@rvsi2//usr2/u/ls-2000/QjobSpec
           => `rvsi2/usr2/u/ls-2000/.listing'
Resolving rvsi2... done.
Connecting to rvsi2[141.183.47.51]:21... connected.
Logging in as root ... Logged in!
==> SYST ...
Server error, can't determine system type.
==> PWD ... done.
==> TYPE I ... done.  ==> CWD /usr2/u/ls-2000 ... done.
==> PORT ... done.    ==> LIST ... done.

    [  <=>                                                                                              ] 3,071          4.45K/s

09:31:15 (4.45 KB/s) - `rvsi2/usr2/u/ls-2000/.listing' saved [3071]

Removed `rvsi2/usr2/u/ls-2000/.listing'.
--09:31:15--  ftp://root:*password*@rvsi2//usr2/u/ls-2000/QjobSpec/QjobSpec
           => `rvsi2/usr2/u/ls-2000/QjobSpec/.listing'
==> CWD /usr2/u/ls-2000/QjobSpec ... done.
==> PORT ... done.    ==> LIST ... done.

    [  <=>                                                                                              ] 1,765          4.50K/s

09:31:15 (4.50 KB/s) - `rvsi2/usr2/u/ls-2000/QjobSpec/.listing' saved [1765]

Removed `rvsi2/usr2/u/ls-2000/QjobSpec/.listing'.
--09:31:15--  ftp://root:*password*@rvsi2//usr2/u/ls-2000/QjobSpec/NOMINAL
           => `rvsi2/usr2/u/ls-2000/QjobSpec/NOMINAL'
==> CWD not required.
==> PORT ... done.    ==> RETR NOMINAL ... done.
Length: 5,732

100%[==================================================================================================>] 5,732        373.18K/s    ETA 00:00

09:31:15 (373.18 KB/s) - `rvsi2/usr2/u/ls-2000/QjobSpec/NOMINAL' saved [5732]

--09:31:15--  ftp://root:*password*@rvsi2//usr2/u/ls-2000/QjobSpec/core
           => `rvsi2/usr2/u/ls-2000/QjobSpec/core'
==> CWD not required.
==> PORT ... done.    ==> RETR core ... done.
Length: 1,177,952

hi yuzh..
the above is part of the output of the script with the debug statement
0
 
yuzhCommented:
Login to rvsi2, and check
       /usr2/u/ls-2000/QjobSpec/core
       file, delete the core file and try again.
0
 
TPolyAuthor Commented:
hi yuzh..
 there is no core files in the directory
0
 
yuzhCommented:
Do you have a dir:
    /usr2/u/ls-2000/QjobSpec/core ?

    do a:
   ls -al /usr2/u/ls-2000/QjobSpec/core
   du -sk /usr2/u/ls-2000/QjobSpec/core

   to find out the story.
0
 
TPolyAuthor Commented:
ftp>  ls -al /usr2/u/ls-2000/QjobSpec/core
output to local-file: /usr2/u/ls-2000/QjobSpec/core?
local: /usr2/u/ls-2000/QjobSpec/core: No such file or directory
ftp>  du -sk /usr2/u/ls-2000/QjobSpec/core
?Invalid command
ftp> du -sk /usr2/u/ls-2000/QjobSpec/core
?Invalid command
ftp>

The above are the output i get when i do
>ls -al /usr2/u/ls-2000/QjobSpec/core  
>du -sk /usr2/u/ls-2000/QjobSpec/core
0
 
yuzhCommented:
You should use the about command in a shell login session, not in FTP mode!

if there is no /usr2/u/ls-2000/QjobSpec/core  dir, why you try to ftp it?
0
 
TPolyAuthor Commented:
eh...
i dont get want you mean.
i ftp because i want to transfer files from the remote computer to my computer
0
 
yuzhCommented:
I mean that you need to use secure shell or telnet to login to your FTP server
and run the above command to check it out.

Warning, do not telnet login as root in-secure, use ssh instead.

0
 
TPolyAuthor Commented:
ls-2000@rvsi2:pts/4<53>
   ls -al /usr2/u/ls-2000/QjobSpec/core ls-2000@rvsi2:pts/4<53>
-rw-rw-r--  1 ls-2000   1177952 May 17 13:33 /usr2/u/ls-2000/QjobSpec/core
ls-2000@rvsi2:pts/4<54>du -sk /usr2/u/ls-2000/QjobSpec/core
1160    /usr2/u/ls-2000/QjobSpec/core
ls-2000@rvsi2:pts/4<55>

this is the output.. can you explain the core?
0
 
yuzhCommented:
Have a look at the following pages to learn something about core:

http://www.linuxgazette.com/local/remap.php?link=issue41/tag/4.html
http://www.network-theory.co.uk/articles/gccdebug.html

If you do a search at EE, you can find more infor above core.
0
 
TPolyAuthor Commented:
ok now i know what's core is abt
hmm so what do i do next with the output i've paste in the previous entry
how do i continue from here?
thanks
0
 
yuzhCommented:
use shell login to the remote server delete the core file, and try to run your script again.
and try in the following command:

du -sk /usr2/u/ls-2000/QjobSpec

to find ou how dig is the dir, if it is very big and you only have a moden connetction, it
might take ages to dwonload all the files!
0
 
TPolyAuthor Commented:
output of du -sk /usr2/u/ls-2000/QjobSpec:

140492  /usr2/u/ls-2000/QjobSpec

btw i'm not allow to delete anything from the remote computers
so is there any other way other than deleting core?
0
 
yuzhCommented:
then you can try to download the whole lot use your FTP script.
0
 
TPolyAuthor Commented:
thanks..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 10
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now