Hey,
I’m pretty new to the scripting stuff, and just want to have a script that will put a cmd into a window that is already open, heres what i have so far
tell application "Terminal"
do script with command "sudo" in window "1"
end tell
i think it is right, but when i run it i get an error:
“terminal got an error:
NSArgumentEvaluationScripError”
what am i doing wrong, and what does this error mean?
Terminal’s dictionary says that ‘with command’ is deprecated. You have also coerced 1 to text by enclosing it in quotes - it probably needs to be a number. Does this work?
tell application "Terminal"
do script "sudo" in window 1
end tell
well i dont get the error anymore with your code, but it doesn’t do the command either it just opens up bounces a lil and shuts down, not doing what i want it to heh.
Rob is correct, sudo alone will not work. You can use “sudo -k” in the code. The -k arguement simply resets the sudo users time stamp to 0. Or you can use “sudo sh” in the code. Also the “with command” has been dropped in later versions of the AppleScript. So, try this code
tell application "Terminal"
do script "sudo sh" in window frontmost
end tell
The above code needs to have an open terminal window. Hope that helps.
well i’m not doing the sudo comand at all, it was just an example heh, but the frontmost thing works in a regular window, but i was trying to make it do it in an eDonkeyClc window, but there is obviously another prob, beacuse it doesn’t work with eDonkey. I was thinking that beacuse it ran in the terminal that it would just treat it as another window, but it does not. so thanks anyway for your help :?
Are you aware that you can issue shell commands directly from a script, without using the Terminal? If you don’t actually need a window, this might be useful.
Dunno what sh means except to be quiet. What happens when you run the command in Terminal? Is it possible that the target of the command is located in a non-standard directory? I’m no shell/unix expert so I can only guess. :?
well the vd command in eDonkey(eDonkey runs in the terminal) is to view your downloads, all i want the script to do for know is automatically enter the vd command…gah i feel so stupid I think i’m just going to give up, but thanks for your help rob and greg.
What it means is that whatever shell you are using in the Terminal (ie, tcsh, bash, ksh, zsh, or whatever) is not the shell that the ‘do shell script’ command uses. Even the default shell of Terminal knows/does more than the default shell of ‘do shell script’.
In your specific case, you probably just need to ge the full path to vd to run it. For example, if vd is at /usr/local/bin/vd you’d need to run the following (NOT in a tell Terminal block):