Forgive the newb questions…I’m a total newb to AS, but I’m so excited I discovered it!
I built this tiny little app that would open terminal past some long text to mount an sshfs drive, then put in the password, and then quit. I was so proud of myself. I used just keystroke to login.
Then I thought, this is Apple, there must be a way to do this in the background. So I found this site and comments about using do shell script. So I did two text fields (user,pass) and a button to mount:
tell application "System Events"
set userLogin to contents of text field "userLogin" as string
do shell script "/Applications/sshfs/bin/mount_sshfs" & userLogin & "@xxx.xxx.xxx.xxx: ~/sshfs/xxx"
set passLogin to contents of text field "passLogin" as string
do shell script "" & passLogin & ""
so I’m having trouble getting it to take in the pass and user. the fields are inside a box, so I’m thinking that maybe that is the reason.
I’m sure this is trivial, but if you can help this newb AS chick I’d be forever thankful
btw, that’s not the whole script, that’s just part of the button event to mount.
Welcome, drdaco! (FYI, I believe we sort of know each other through a particular “localhost”. ;))
Try using statements like this outside of tell blocks for other applications:
on clicked theObject
set userLogin to contents of text field "userLogin" of box "whatever" of window "whatever"
set passLogin to contents of text field "passLogin" of box "whatever" of window "whatever"
set userLogin to contents of text field "userLogin" of box "whatever" of window of theObject
set passLogin to contents of text field "passLogin" of box "whatever" of window of theObject
tell box "whatever" of window of theObject
set userLogin to contents of text field "userLogin"
set passLogin to contents of text field "passLogin"
-- do shell script
(You don’t need System Events to use
do shell script; That’s part of StandardAdditions.)
You know Mikee? wow…I know it’s a small world, but that’s really small hehe
I did what you wrote and it worked to send the comand! YAY
but now my problem is that I realized that by using “do shell script” I am only opening a portal to send the command. I was thinking it opened a hidden terminal, and I learned that’s not the case.
So I’m trying to mount using sshfs a folder but it’ll ask me for a password…
I thought perhaps a bypass would be to setup a public key/no pass ssh and then use it…but I wanted my proggy to be more general than that.
I could go back to doing the “open Terminal” that I had coded originally (which worked wonderfully btw) but I was hoping to do a cool little proggy that looks a feels like a proggy, not just a script
I would be happy to also embed a terminal window in my proggy and just have those buttons for when I need to mount those drives…like make my personal terminal proggy.
Anyhow, any ideas are very appreciated… thanks for teaching me the button thing!!!
Can you include the password in the command?
All I can really do is point you here: Technical Note TN2065: do shell script in AppleScript
actually that was excellent! I’ll have to read it more carefully and I’ll post here what my solution (hopefully) was.
thanks again! you guys (gals?) have been super!