I have written a simple script that makes use of the “do script” command to instruct the Terminal to telnet to my NAS server.
It all worked fine.
Then not. I was writing another script which also used “do script”, and it simply stopped working. If the script is executed, the Terminal will do everything it is told except “do script”'s: Launch, then quit when instructed.
The “do shell script” command still works, but in order to automate telnet, “do script” is the only trick I have found.
The other user on my machine does not have the same problem, “do script” still works. I have repaired permissions, but to no avail.
I don’t know a lot about that myself, I just use it occasionally when I’m SSHing into somewhere. Maybe that could help. I think you need to put in a new “-e” at the start of every new line.
The difference between “do shell script” and “do script” is the former sends unix script to the system without launching the Terminal. The latter works a bit like “System Events”, it basically tells the Terminal to enter a line of text and press Enter. That is why you need to specify in which window the script should be entered.
@ Lambo
I’m a bit confused: where do you suggest I add this extra “-e”? it cannot be added after or before “do script”.
I revived an old iBook g3 as the g5 will be taken away soon. I copied the above script into my newly created ~/Library/Script folder… And same problem.
When reaching ‘Tell application “Terminal”’, the Terminal activates, stays open 7 seconds (as there are 2 ‘delay’ commands, 5 seconds and later 2 seconds), and quits, doing absolutely nothing else.
Can I just point out this is the exact same script (word for word) that was working on the g5 2 days ago, and is still working on the g5 when launched by the second user. Isn’t that a bug from space or what??
Oh, and btw, below is the script I was writing when the ‘do script’ stopped working. I was using it instead of the ‘do shell script’:
Sorry etien, it was early in the morning, and I got your question the wrong way round. You can forget about “osascript”. It’s for doing applescripts from the terminal, not doing shell scripts from applescript.
this works for me. could it be that you are on a different version of OS X now (and thus a different version of AppleScript)?
i’m using 10.4.5, and although i did need to tweak the script a bit (for some reason the telnet on our Solaris box needs to be told explicity what the username is from the command line) it runs fine. of course it gives me errors on commands, ‘8’, and ‘y’, but that is to be expected. here is the changed code:
I simply trashed the com.apple.Terminal.plist situated in ~/Library/Preferences. It worked. It is a great shame I did not think of this earlier. Don’t know why, simply assumed Terminal didn’t have its own plist!
The fact that it worked with the other user should have been a hint, too, that something was amiss in my own prefs folder.
Spoke too fast. Trashing the plist worked on the G5, but not on the iBook G3.
I tried to replace do script “<>” in front window with do script with command “<>” in front window, and although it did get the Terminal to execute the command, it also opened a new window for each new command, which is obviously useless!
sorry to bump my own topic, but I thought I’d just check anyone who might’ve missed this sees it.
Still a mystery. I’ve tried trashing any pref file that just might have any remote relation to applescript.
No effect. Which is even weirder considering trashing the com.apple.Terminal.plist worked the first time, but not the times after that!
Since then, I’ve recloned my system from another partition on which the command worked. Worked 1 day that is, then the command stopped working again.
Obviously a corruption finds its way into my system and targets this command specifically, but I am yet to find where it might come from.
What I’d like for a start though, is to find at least one person in the whole mac world with a similar problem! I have asked everywhere, noone has ever seen this happen.
So as I’ve said before, any comment very much appreciated.