Jump to content

Connecting to remove server(s)


Steven_

Recommended Posts

Hi

 

Firstly, this may be a feature that can be handled by the Worklows addition to Alfred, though I don't have the skills to create the required scripts...

 

I spend a large amount of my day working off Servers. Either Windows 2003/2008 or Mac OSX Server. To access the servers I use the CMD + K shortcut to access the 'Connect to server' dialog, then choose the server I want to connect to etc etc.

 

I'd really like to be able to invoke Alfred, type a keyword (maybe 'srv') along with the required server name and have that server mount and open in finder.

 

Hope that makes sense, if anyone can do this with Workflows I'd love to know how they've made it happen!

 

Cheers

 

Steven

Link to post

Hi and thanks Ken that's great!

 

I'd like to have a method of typing a abbreviation of the server name (without the smb/afp part) after srv to make it quicker. Using what you've given me and what I can find by googling aroundI'll see if I can work out the AppleScript for it.

 

Will post back here if it works.

 

Cheers

 

Steven

Link to post

One kinda of easy thing would be to make a workflow that will allow you to add locations/servers.. So do something like 'addserver smb://HTPC' and that would save it in a list. Then use 'srv <name>' and it would show a list of saved servers to select from.

 

I can prob make it tonight it you want?

Link to post

Hi both

 

Thanks for your help, it really is much appreciated :)

 

David, I've tried the workflow above. When I enter a server using 'addserver' I get an error message in Growl/Notification Centre. The error message is cut off due to it's length and the available space in the Notification Centre window, but it starts:

 

 New Server

Warning: array_combine(): Both parameters should have an equal number of elements...

 

Just to make sure I'm entering the data correctly, I input this into the 'addserver' workflow in Alfred:

 

'addserver afp://192.168.0.100'

 

Once again, thanks for the help 

 

Steven

Link to post

Yeah sorry I forgot to tell you how to enter them

 

Use:

Syntax
addserver <name> <path>

Example
addserver file_server afp://127.0.0.1

 

My bad.. I added a "name" so you could have an easily recognizable name for the servers too if you wanted.. One downside to it is that it doesn't spaces in the name right now. I can fix that for you later if you'd like.

 

Let me know if you get it working

Link to post

I'll give you a quick overview.

 

addserver -

Accepts the input and then splits it into an array based on <space> so it can grab the name and server values separately. It checks to see if servers.json exists. If so, adds the new entry to the servers list and writes it back to the json file. If the servers.json file doesn't exist, it makes a new array (the single, new server), and writes that to a new servers.json. Echos success.

 

srv -

Looks for the servers.json file. If it's there, it reads the file and formats the server list as xml for Alfred feedback. If the file doesn't exist, it returns a feedback item saying that no servers are available.

Link to post
How do I remove servers from the list? So when I type "srv" it stops showing an unused address? 

 

Thanks

 

I didn't add that because it wasn't something that Steven_ originally asked for. I guess I could make a quick edit to remove one by typing 'srv' and in the list, highlight one and press cmd+enter. I'll try to get it posted later.

Link to post
Just made a little update to this to make it so that you could remove servers from the list.

 

Just use the srv keyword to get your server list, highlight the server you want to delete, and press cmd+enter to delete it from the server list

 

Download

Man, you absolutely ROCK. At your feet :/_

Link to post
It would be awesome if you could type `srv <name> <volume>` and have Alfred filter the volumes on that server as an instant search. For example, I have these volumes on my NAS:

 

http://cl.ly/image/2q101M1s2f2C

 

That would mean I could type `srv nas media` to access the Media volume on my NAS. :)

 

I have this script

 

on alfred_script(argv)
	set myList to splitString(argv, " ")
	set numItems to count myList

	if numItems is less than 3 then
		display dialog "You need to pass at least 3 arguments"
		return
	end if

	set theServer to item 1 of myList
	set theUsername to item 2 of myList
	set thePassword to item 3 of myList
	set theVolume to item 4 of myList

	set theUrl to "afp://" & theUsername & ":" & thePassword & "@" & theServer

	if numItems is 4 then
		set theUrl to theUrl & "/" & theVolume
	end if

	--display dialog theUrl

	tell application "Finder"
		mount volume theUrl
	end tell
end alfred_script

to splitString(aString, delimiter)
 set retVal to {}
 set prevDelimiter to AppleScript's text item delimiters
 log delimiter
 set AppleScript's text item delimiters to {delimiter}
 set retVal to every text item of aString
 set AppleScript's text item delimiters to prevDelimiter
 return retVal
end splitString

 

 

The only problem is that it won't work if the volume has a space in it.  I can't figure out how to escape a space when entering the query in Alfred

Link to post
It would be awesome if you could type `srv <name> <volume>` and have Alfred filter the volumes on that server as an instant search. For example, I have these volumes on my NAS:

 

http://cl.ly/image/2q101M1s2f2C

 

That would mean I could type `srv nas media` to access the Media volume on my NAS. :)

 

I have this script

on alfred_script(argv)
	set myList to splitString(argv, " ")
	set numItems to count myList

if numItems is less than 3 then
display dialog "You need to pass at least 3 arguments"
return
end if

set theServer to item 1 of myList set theUsername to item 2 of myList set thePassword to item 3 of myList set theVolume to item 4 of myList set theUrl to "afp://" & theUsername & ":" & thePassword & "@" & theServer if numItems is 4 then set theUrl to theUrl & "/" & theVolume end if --display dialog theUrl tell application "Finder" mount volume theUrl end tell end alfred_script to splitString(aString, delimiter) set retVal to {} set prevDelimiter to AppleScript's text item delimiters log delimiter set AppleScript's text item delimiters to {delimiter} set retVal to every text item of aString set AppleScript's text item delimiters to prevDelimiter return retVal end splitString

 

 

 

 

The only problem is that it won't work if the volume has a space in it.  I can't figure out how to escape a space when entering the query in Alfred

Link to post
  • 4 weeks later...

Just made a little update to this to make it so that you could remove servers from the list.

 

Just use the srv keyword to get your server list, highlight the server you want to delete, and press cmd+enter to delete it from the server list

 

Download

 

Please change line 4 in addserver.php from:

 

 

$input = explode( " ", $input );
 
to:
 
$input = explode( " ", $input, 2 );
 
UNCs can have spaces in them.
 
 
Link to post

Please change line 4 in addserver.php from:

 

 

$input = explode( " ", $input );
 
to:
 
$input = explode( " ", $input, 2 );
 
UNCs can have spaces in them.
 
 

 

Awesome, will do. I've been using explode() forever and I thought I knew the full syntax so I had never looked back to notice there was a limit parameter. I'll get this added.

 

Thanks

Link to post

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...