Solved

problem with ftp script

Posted on 2004-08-26
20
325 Views
Last Modified: 2012-05-05
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
Comment
Question by:TPoly
  • 10
  • 9
20 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 100 total points
Comment Utility
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
 

Author Comment

by:TPoly
Comment Utility
if i do not login as root, i cld not ftp into the computer
0
 

Author Comment

by:TPoly
Comment Utility
hi yuzh
btw is the secure shell/ftp able to use the same codes?

can debian use that?

thankssss
0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
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
 
LVL 23

Expert Comment

by:Mysidia
Comment Utility
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
 

Author Comment

by:TPoly
Comment Utility
++ 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
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
Login to rvsi2, and check
       /usr2/u/ls-2000/QjobSpec/core
       file, delete the core file and try again.
0
 

Author Comment

by:TPoly
Comment Utility
hi yuzh..
 there is no core files in the directory
0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
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
 

Author Comment

by:TPoly
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 38

Expert Comment

by:yuzh
Comment Utility
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
 

Author Comment

by:TPoly
Comment Utility
eh...
i dont get want you mean.
i ftp because i want to transfer files from the remote computer to my computer
0
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
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
 

Author Comment

by:TPoly
Comment Utility
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
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
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
 

Author Comment

by:TPoly
Comment Utility
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
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
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
 

Author Comment

by:TPoly
Comment Utility
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
 
LVL 38

Expert Comment

by:yuzh
Comment Utility
then you can try to download the whole lot use your FTP script.
0
 

Author Comment

by:TPoly
Comment Utility
thanks..
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now