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

John Doe 57

macrumors 65816
Original poster
Jan 26, 2008
1,333
3
Los Angeles, CA
Can i use AppleScript to Force open Safari. My Safari is broken and only responds to this:
sudo -k; sudo -b '/Applications/Safari.app/Contents/MacOS/Safari'

This is the command I use to open Safari with the help of Terminal.

Is there some way that I can get a script that runs off Terminal commands? And can I save that as an application that would load up Safari?
 

chas0001

macrumors 6502a
Sep 18, 2006
804
0
Alicante, SPAIN
Can i use AppleScript to Force open Safari. My Safari is broken and only responds to this:
sudo -k; sudo -b '/Applications/Safari.app/Contents/MacOS/Safari'

This is the command I use to open Safari with the help of Terminal.

Is there some way that I can get a script that runs off Terminal commands? And can I save that as an application that would load up Safari?

You can issue terminal commands in AppleScript using the command

do shell script " ** put your code here ** " e.g.

do shell script "ls -l"

You can then save the AppleScript as an Application using Script Editor.

Is that what you meant?
 

John Doe 57

macrumors 65816
Original poster
Jan 26, 2008
1,333
3
Los Angeles, CA
Its not working. Here is what I have:

do shell script "sudo -k; sudo -b '/Applications/Safari.app/Contents/MacOS/Safari'"

do shell script "ls -l"

do shell script "sudo shutdown -h now"gmbmatrix" with administrator privileges

Picture 1.png
 

chas0001

macrumors 6502a
Sep 18, 2006
804
0
Alicante, SPAIN
Its not working. Here is what I have:

do shell script "sudo -k; sudo -b '/Applications/Safari.app/Contents/MacOS/Safari'"

do shell script "ls -l"

]do shell script "sudo shutdown -h now"gmbmatrix" with administrator privileges

View attachment 117396

Thats because you have typos. All you need to open safari is

do shell script "sudo -k; sudo -b '/Applications/Safari.app/Contents/MacOS/Safari'" password "gmbmatrix" with administrator privileges

You dont need the last 2 'do shell scripts' because they were purely examples. Just for future reference the typo was due to double quotes in the wrong place and the missing word Password i.e. do shell script "sudo shutdown -h now" password "gmbmatrix" with administrator privileges

I am sure that you have tried to resolve the problem with safari by removing it and its preference files then downloading the latest version of Safari from the Apple Website.
 

merl1n

macrumors 65816
Mar 30, 2008
1,095
0
New Jersey, USA
Can i use AppleScript to Force open Safari. My Safari is broken and only responds to this:
sudo -k; sudo -b '/Applications/Safari.app/Contents/MacOS/Safari'

This is the command I use to open Safari with the help of Terminal.

Is there some way that I can get a script that runs off Terminal commands? And can I save that as an application that would load up Safari?

Excuse me for asking, but what do you mean when you say Safari is broken? What are your symptoms? If you can open it in Terminal, then I don't think it's broken.

It could be a binding issue or your "locate db" is bad or something else like a bad cache file. Please explain.
 

John Doe 57

macrumors 65816
Original poster
Jan 26, 2008
1,333
3
Los Angeles, CA
Yeah what I mean is that Safari does not open anymore. On May 20th it just stopped working. I couldn't get it to open. It would just load and load. Firefox works perfectly. I've deleted files in the preferences and it seems to do nothing. Terminal is the only way that I can open Safari. But I can't download anything using Safari anymore, I have to use Firefox. So I created a new username and tried to see if Safari would work - It did. But that is just plain annoying! Logging into another account just to use Safari, its stupid really. And as for this new issue regarding keychains, I don't know. That box appears during startup and anytime I click on a bookmark in Safari.

If you know how to fix it - please help me.
 

merl1n

macrumors 65816
Mar 30, 2008
1,095
0
New Jersey, USA
Yeah what I mean is that Safari does not open anymore. On May 20th it just stopped working. I couldn't get it to open. It would just load and load. Firefox works perfectly. I've deleted files in the preferences and it seems to do nothing. Terminal is the only way that I can open Safari. But I can't download anything using Safari anymore, I have to use Firefox. So I created a new username and tried to see if Safari would work - It did. But that is just plain annoying! Logging into another account just to use Safari, its stupid really. And as for this new issue regarding keychains, I don't know. That box appears during startup and anytime I click on a bookmark in Safari.

If you know how to fix it - please help me.

You just proved my point. If it works with another user account then it's not broken. Most likely your Safari plist file is corrupted or you have some bad user cache file.

This is what you should do:

1. Download OnyX (a free maintenance utility).
2. Go into your homedirectory/Library/Internet Plug-Ins and remove (you can move it all to your desktop or another folder) everything.
3. Delete the "com.apple.Safari.plist" and "com.apple.Safari.RSS.plist" files in your homedirectory/Library/Preferences folder.
4. Run OnyX and clear ALL caches (System, Fonts, User, etc.). Note, in each tab, execute the command. When it finished in that tab, it will ask you to reboot. Say NO. Go on to the next tab and repeat until all tabs are done. THEN REBOOT.

Now see if you have any problems launching Safari.
 

merl1n

macrumors 65816
Mar 30, 2008
1,095
0
New Jersey, USA
You just proved my point. If it works with another user account then it's not broken. Most likely your Safari plist file is corrupted or you have some bad user cache file.

This is what you should do:

1. Download OnyX (a free maintenance utility).
2. Go into your homedirectory/Library/Internet Plug-Ins and remove (you can move it all to your desktop or another folder) everything.
3. Delete the "com.apple.Safari.plist" and "com.apple.Safari.RSS.plist" files in your homedirectory/Library/Preferences folder.
4. Run OnyX and clear ALL caches (System, Fonts, User, etc.). Note, in each tab, execute the command. When it finished in that tab, it will ask you to reboot. Say NO. Go on to the next tab and repeat until all tabs are done. THEN REBOOT.

Now see if you have any problems launching Safari.

Sorry I forgot about your keychain problem.

In /Applications/Utilities, there is an application called Keychain Access. Launch it. Under the "Keychain Access" menu, select "Keychain First Aid". Run that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.