I want to get a return of all the sub directories(folders) within a main directory. I tried the following script, and it worked…kinda. I gave me back too much info. All I want is the names of the sub directories highlighted in black.Any way to cut this down?
set myScript to "USER=username
PASSWD=xxxxxx
HOST=ftp.mywebsite.com
ftp -n $HOST <<EOF
user $USER $PASSWD
ls
quit
EOF
exit 0"
do shell script myScript
returned:
"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
dr-xr-x— 7 root psaserv 4096 May 30 2008 statistics
I guess, someone will use grep or sed and give you a decent solution. Meanwhile, you can use:
set thetext to "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
dr-xr-x--- 7 root psaserv 4096 May 30 2008 statistics"
set thelist to {}
set allparas to every paragraph in thetext
repeat with apara in allparas
set x to last word of apara
set end of thelist to x
end repeat
thelist
which means in your script, you have to do this:
set thecmd to do shell script myScript
set thecmd to thecmd as text ------not sure if this is necessary
set thelist to {}
set allparas to every paragraph in thecmd
repeat with apara in allparas
set x to last word of apara
set end of thelist to x
end repeat
thelist