?
Solved

problem with ftp script

Posted on 2004-08-26
20
Medium Priority
?
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 9
20 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 300 total points
ID: 11910731
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
ID: 11910898
if i do not login as root, i cld not ftp into the computer
0
 

Author Comment

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

can debian use that?

thankssss
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 38

Expert Comment

by:yuzh
ID: 11910985
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
ID: 11919371
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
ID: 11928072
++ 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
ID: 11928416
Login to rvsi2, and check
       /usr2/u/ls-2000/QjobSpec/core
       file, delete the core file and try again.
0
 

Author Comment

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

Expert Comment

by:yuzh
ID: 11928759
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
ID: 11928777
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
 
LVL 38

Expert Comment

by:yuzh
ID: 11928810
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
ID: 11928824
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
ID: 11929159
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
ID: 11937727
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
ID: 11938093
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
ID: 11938246
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
ID: 11938656
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
ID: 11938898
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
ID: 11938955
then you can try to download the whole lot use your FTP script.
0
 

Author Comment

by:TPoly
ID: 11939076
thanks..
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

762 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