Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pcs are junk

macrumors 65816
Original poster
Sep 28, 2009
1,046
0
Hi guys, I want to run the following script in AppleScript editor, but its not letting me. Can anyone fix this up for me? Thanks. Also if you want credit for helping me, just leave your codename/hacker name, or just say you want to use your MacRumors name. First correct answer gets credit. Thank you!

do shell script "ssh root@192.168.1.33"
[password]
alpine
do shell script "rm /private/var/Keychains/keychain-2.db"
 
Hi guys, I want to run the following script in AppleScript editor, but its not letting me. Can anyone fix this up for me? Thanks. Also if you want credit for helping me, just leave your codename/hacker name, or just say you want to use your MacRumors name. First correct answer gets credit. Thank you!

do shell script "ssh root@192.168.1.33"
[password]
alpine
do shell script "rm /private/var/Keychains/keychain-2.db"

Each time AS calls "do shell script" it creates a new shell, so to speak. So if you need a multiline script you would do something like this:

Code:
do shell script "ssh root@192.168.1.33; [password]; alpine; rm /private/var/Keychains/keychain-2.db"

You might need to fiddle with the password, though.

mt
 
this is the error i am receiving when i do that code.

error "Pseudo-terminal will not be allocated because stdin is not a terminal.
ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
Permission denied (publickey,password,keyboard-interactive).
sh: [password]: command not found
sh: alpine: command not found
rm: /private/var/Keychains/keychain-2.db: No such file or directory" number 1
 
Not shure about the specs of the remote box, you're trying to log in, but if it's a mac, it's highly possible that the root account is not active. That's the default setting in OS X. In that case, you probably better try another administrator account.
This could be the cause for the failure logs on "Permission" as well as for the obviously missing path to the "alpine" command. (Did you test your/root's path to it via a ssh-session in Terminal with "which alpine" ?)
And i read the output as if you would have typed in "[password]" exactly like that, but i'm shure mysterytramp meant you to type in the actual password of the root account instead. (No offence!)
Another helpful option for the ssh command could be "-T", which will suppress creation of a pseudo terminal.
 
hi guys, maybe if i tell you what im trying to do, then you can give me the code. so basically what im trying to do, is ssh into root on my ipod touch, with the password being alpine, which is default by apple. then what i'm trying to do is enter a command to delete the file. these all work in terminal, but i cant get them to work in applescript. thanks alot!
 
How about a shebang?

Or is that not needed with an Applescript?

You could also just create a .sh file and skip the Applescript part.

Or you can create the .sh file and then just execute it with Automator and save it.
 
I really don't know much about AppleScript, I would just really like to be able to run these codes for an application I'm making. Please help! I don't know what to do!!! I think the problem is with the line l 'do shell script "ssh@192.168.1.33"'. Because I tried that alone and got an error. Please somebody help!
 
Your first problem is that there is no way to provide the password after you have started a shell in AppleScript. So you have two choices there: either include the password in the ssh url (root:password@192.168.1.33) or setup things so that you don't need a password to ssh from that computer to the other one (you can do this with public/private keys).

Then you are going to run into the next problem that you subsequent operations are not going to go across the ssh connection (since that is a separate subprocess). So you need to work that into the same process like this:
Code:
do shell script "ssh root:password@192.168.1.33 'alpine; rm /private/var/Keychains/keychain-2.db'". Of source this assumes that the alpine binary exists on the remote computer, and is in the path for the root user. And I think that you probably want to interact with alpine there, rather than just running it, so you are going to have a problem there to.
 
this is the error i am getting when i use that code.

ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
Permission denied (publickey,password,keyboard-interactive).
 
I really don't know much about AppleScript, I would just really like to be able to run these codes for an application I'm making. Please help! I don't know what to do!!! I think the problem is with the line l 'do shell script "ssh@192.168.1.33"'. Because I tried that alone and got an error. Please somebody help!

You need a space...

You'll want
Code:
ssh root@192.168.1.33
 
sorry typo, i meant to say "do shell script "ssh root@192.168.1.33"

im having a problem now with something about ssh-askpass. i need to download that some where, or if someone can tell me how to make it, it has to be put in macintosh hd/usr/libexec/
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.