Visit Our UNIX and Linux User Community


Return all sub directories on ftp server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Return all sub directories on ftp server
# 1  
Old 09-30-2009
Return all sub directories on ftp server

Hey guys,

I'm new to the programming world in general, and I only write in applescript so far. I am trying to find a shell script that will return a list of all the sub directories (or folders) within a directory on my ftp server. The server needs a username and password. I would assume the translation to applescript would be something like below:


Code:
set ftp_path to "/path/to/dir/"
set ftp_name to "username"
set ftp_pw to "XXXXX"
set ftp_server to "ftp.mywebsite.com"
tell application "Finder"
    do shell script "missing shell command"
end tell

Is this wrong?
# 2  
Old 09-30-2009
if I'm not mistaken, 'do shell script' doesn't allow for line breaks. You could put the script below into a file and call
Code:
do shell script "thescript"

Code:
USER=username
PASSWD=xxxxxx
HOST=ftp.mywebsite.com
ftp $HOST <<EOF
user $USER
$PASSWD
ls
quit
EOF
exit 0

# 3  
Old 09-30-2009
You're correct. But when I ran the following script, I got the following return:

Code:
set theScript to "USER=username
PASSWD=XXXXX
HOST=ftp.mywebsite.com
ftp $HOST <<EOF
user $USER
$PASSWD
ls
quit
EOF
exit 0"
do shell script theScript

obviously, I put in my info. I double checked it to make sure I didn't misspell anything

Returned:

"Name (ftp.mywebsite.com:HOME): Login incorrect.
?Invalid command.
Please login with USER and PASS
Please login with USER and PASS
Please login with USER and PASS
Please login with USER and PASS"

Is that something that might be an issue with the applescript command or the shell?
# 4  
Old 09-30-2009
Code:
USER=username
PASSWD=xxxxxx
HOST=ftp.mywebsite.com
ftp -n $HOST <<EOF
user $USER $PASSWD
ls
quit
EOF
exit 0

# 5  
Old 09-30-2009
Thanks that worked. Is there any way to check a sub directory's list such as:

ftp.mywebsite.com-->sub A-->sub 1, sub 2, sub 3

---------- Post updated at 07:30 PM ---------- Previous update was at 07:26 PM ----------

Also, I got a return, but I got a lot of unneeded info. I only need the names of the directories. Is there any way to filter them out?

Names in Black:

"Illegal EPRT command

drwxr-xr-x 2 root root 4096 May 30 2008 bin
drwxr-x--- 2 root psaserv 4096 Jul 23 16:06 conf
drwxr-xr-x 2 root psaserv 4096 May 30 2008 error_docs
drwxr-xr-x 2 root root 4096 May 30 2008 etc
drwxr-xr-x 2 root root 4096 May 30 2008 lib
drwxr-x--- 2 root psaserv 4096 Jun 6 2008 pd
drwx------ 2 comcastcs root 4096 May 30 2008 private
dr-xr-x--- 7 root psaserv 4096 May 30 2008 statistics

Previous Thread | Next Thread
Test Your Knowledge in Computers #483
Difficulty: Easy
IDEs do not provide automated compile/build features and other tools that make the software development process easier and faster.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Recurse directories and return random file

I have a nice program to change the background but I want it to operate on subdirectories as well. # Script to randomly set Background from files in a directory while true;do # Directory Containing Pictures DIR="/home/pc/Pictures" # Internal Field Separator set to newline, so file names... (4 Replies)
Discussion started by: triplemaya
4 Replies

2. Shell Programming and Scripting

Clear contents of specified directories, then return exit status

Hello, this is my first post here. I'm attempting to write a bash shell script to rm the contents of a directory without deleting the directory, specifically in OS X 10.10 . Here's what I have: function clear() { USER="$USER" DIR=$1 rm -rfv /Users/"$USER"/library/$DIR/* } clear... (6 Replies)
Discussion started by: YouNicks
6 Replies

3. UNIX for Dummies Questions & Answers

Sort directories in 'D' on FTP server

Hello, There are 3 directories on FTP server with format yyyymmddhhmiss. Can someone please let tell me how do I sort these directories in descending order. I only have get the files from the latest directory on FTP server. ftp>ls -l 20150707011229 20150707061229 20150707131225 ... (2 Replies)
Discussion started by: pavan_test
2 Replies

4. Red Hat

Implement FTP server on RHEL server without using FTP client

We have RHEL 5.8 in our environment, I had a query whether we can implement an FTP server using vsftpd package and Linux configurations like setsebool without using any external FTP clients like FileZilla etc. I am very confused on this. The FTP functionalities that should be present are download &... (3 Replies)
Discussion started by: RHCE
3 Replies

5. Shell Programming and Scripting

Return Value from a FTP shell script

Hello folks,,, I am calling a Unix shell script from java. The unix script is transferring a file through FTP. I wonder how can I confirm whether the script has been executed properly without any error. Is there any way to find the return value from the script. My FTP script is given below ... (3 Replies)
Discussion started by: dinesh1985
3 Replies

6. UNIX for Dummies Questions & Answers

Any way to grep a string in directories and return the result with diskusage aswell?

What Im basically trying to do is this: I have a small script that can grep any parameter entered into a search string, then print to the screen the name of each file the parameter appears in as well as the file path, ie the directory. The code Im using just for this is.... Directory... (3 Replies)
Discussion started by: Eddeh
3 Replies

7. IP Networking

FTP Return 32

Dear All, I have problem when uploading files the FTP Server threw message like this : ftp return 32. Files not get uploaded. OS is Sun Soalaris 2.10 Please help what is the meaning of that message... Thanks (3 Replies)
Discussion started by: wilsonSurya
3 Replies

8. UNIX for Dummies Questions & Answers

FTP Return Code

Hi All, I have a problem to identify the error code thrown by FTP Server while uploading files. The message is : ftp return 32. I couldn't find out what is the meaning of that. :confused: OS is Sun Solaris 2.10. Anyone can help? Thanks a lot (1 Reply)
Discussion started by: wilsonSurya
1 Replies

9. Shell Programming and Scripting

return ftp status

Hello, I still have problems when trying to figure out if the status of an ftp was successful. I ftp to different types (nt, vax, unix, etc...) of machines. I am trying to write a universal script that will ftp a file and then check to see if the ftp was successful. I have tried the... (12 Replies)
Discussion started by: blt123
12 Replies

10. UNIX for Advanced & Expert Users

FTP return value

Hi guys, I am having a problem to determine if the FTP request I had was successful or not... Here is what I do: In a shell script I call another shell script to do the FTP like: #!/bin/ksh echo "Hello..." ... # call do_ftp.sh do_ftp.sh $SERVER $USR $PASS $FILE.... status=$? if ; then ... (7 Replies)
Discussion started by: Shaz
7 Replies

Featured Tech Videos