Connect to Server Using Applescript

Hi All,
learning applescript, I would like to write a script for almost all the stuff I do repeatedly at my MAC.
I have trying to write a script that would allow me to connect to the server and use an application in that server an then connect to ftp.
here is the process in details:

  1. go to finder
  2. Connect to server
  3. select the volume you want to mount to, in my case it’s “afp://server_address/Software”
  4. select Mac folder from Software
  5. select RBrowswerLite from Mac folder
  6. select GO…then FTP SITES…
  7. type in the FTP site you want to connect to
  8. look at the a particular folder
  9. download all content to a specific folder

I tried working witht this script, but got stuck on the RBrowswerLite part.

tell application "Finder"
	mount volume "afp://server_addreess/Software/Mac/RBrowserLite"

	tell application "RBrowserLite"
		mount volume "desired_ft_location"
	end tell

end tell

any suggestion on what to do next would help a lot.

thanks
Bill

Would you clarify what you mean by “got stuck on”?

when I run the script, a windows pops up asking me to choose an application, I don’t think it recognizes RBrowserLite as an application.
not sure how to fix that problem.

bill

hi bill,

i don’t think you can:

tell application "RBrowserLite"
       mount volume "desired_ft_location"
   end tell

if the application is on the mounted server volume. why don’t you install RBrowserLite locally, mount the volume and then just tell RBrowserLite where to put the downloads?

The problem is not that AppleScript doesn’t recognize a particular application as an application - it might well be that the application isn’t scriptable.

how can I find out if RBrowserLite is scribtable?

if the application is on the mounted server volume. why don’t you install RBrowserLite locally, mount the volume and then just tell RBrowserLite where to put the downloads?

I am not the system admin. for the machine I am working on.

bill

None of the info I can find about it mentions the word AppleScript, so I suspect it is not.

i have RBrowserLite installed on my computer and i can access the dictionary. the command bill uses seems wrong according to the dictionary:

RBrowser's scripting suite	RBrowser's specific classes and commands.
geturl‚v : Opens an ftp URL
geturl reference : the object for the command
openurl‚v : Opens an ftp URL
openurl reference : the object for the command
application‚n [inh. application; see also Standard Suite] : RBrowser's top level scripting object.
elements
contains documents, windows.

perhaps it’s just a syntax error?

you could also try using the built in unix ftp program like this:

tell application "Finder"
	mount volume "afp://server_addreess/Software/Mac/RBrowserLite"
end tell

do shell script "ftp -o /path/to/output/output_file ftp://user:password@servername_or_ipAddress/%2fpath/to/file/to/download"

type “man ftp” at the terminal for more details on the syntax i’m using for this.

hi waltr and all,
I have ran the suggested script

[b]tell application “Finder”
mount volume “afp://server_addreess/Software/Mac/RBrowserLite”
end tell

do shell script “ftp -o /path/to/output/output_file ftp://user:password@servername_or_ipAddress/%2fpath/to/file/to/download”[/b]

and I keep getting unknown port. can you please help me. why I am getting this message?
also, do you think it’s a good idea to display username and password in the script! And, where can I access the dictionary for RbrowserLite?

thanks
bill

According to its man page, ftp supports a -P switch for setting the port it will use. Then you must discover what port RBrowserLite is using if not 21.

I don’t like to put passwords in a script. I use this handler, known to work on your own machine. You’ll have to see if it works with your server:

-- IF you don't want to put your password in clear text in a script, then you can add your password in the Keychain Access application and use it from your script. 
-- In Keychain access, click File>New Password Item..., give it a name, put your account shortname in account, and enter the password. I called mine ASPW. Highlight it in the password list and under the Attributes button enter its kind as generic key. This is chosen because there aren't many of them and the search is much faster. 

-- The script used  is as follows:
to getPW(KeyName)
	tell application "Keychain Scripting"
		launch
		tell current keychain to tell (some generic key whose name is KeyName) to set PWD to password
	end tell
end getPW

-- This is just a test for your PW
set IPW to text returned of (display dialog "Enter your password" default answer "Password here" with hidden answer)
if IPW = getPW("ASPW") then beep 3

hi bill, adam,

nice script there adam. i’ll probably start using that or something similar.

bill, one thing i’d have you check is this part of the ftp script:

servername_or_ipAddress/%2fpath/to/file/to/download

make sure you are including the %2f in your path. that’s pretty important. so if the path was “/my/really/important/file”, then the path in our ftp script would be:

servername_or_ipAddress/%2fmy/really/important/file

i’m just trying to figure out where i might have a problem with that script.

i think RBrowserLite uses a pretty standard port. however, as adam said, you certainly can specify the port if that is the problem.

finally, i do like adam’s password script, but if you are going to compile your AppleScript i think it’s ok to have a password in there. if anyone knows that this is incorrect i’d appreciate a heads up. also, ftp sends your password in the clear anyway, no? we’re not really talking a high security transaction here.