Hide Application through command line in AS

Searched for it but only found finder way of doing hides.

Is there a way to hide an application through command line?

thanks

slash:

See if this may get you what you are looking for.

there are several way to hide an application using applescript.
i don’t know if there’s a specific unix command for hiding processes, but you can run an applescript from the command line, by using “osascript”.
you can either call a script file (osascript somescript.scpt) , or use one line command, (osascript -e “an applescript command”) but then you’ll probably have to escape some nasty quotes.

Personally, I’d probably use something like this (change process name to suit):

tell application "System Events" to set visible of process "Safari" to false

slashdot, is there a particular reason why you need this to be through a command line?

For most running applications, System Events can respond with a list of properties, one of which is “visible”. The real issue in pursuing a shell script method of setting the “visible” property, is to find out where System Events looks to get it.

tell application "System Events" to get properties of process "Safari" -- with Safari running

I forgot to say in my previous post that if you save an applescript as an application, you can easily run it from the command line:

With this saved as Visible.app on my Desktop:

tell application "System Events" to set visible of process "Safari" to false

I run this in the terminal: open ~/Desktop/Visible.app
. I don’t have any luck with osascript -e which is the command line leader for an applescript line.

I’m still curious about why one would particularly want to pursue a shell script approach, given that System Events is already running - and that “do shell script” will launch an invocation of a shell (with all that that entails) - just to achieve something relatively trivial that System Events can already provide. (There may be a perfectly good reason - I’m just trying to determine what that might be.)

Since the author of this thread isn’t telling us, Kai, I’m assuming that he or she has a shell script that grabs data from an application that he doesn’t want the current user to see. Perhaps he wants to run the application, hide it immediately, then quit it. I agree that I would do this from an AppleScript, but then we don’t know what’s going on.

Well the particular reason for this is mainly to not inconvenience the user with issues of connectivity. Since the app in question has an inability to remain connected on to the network if there are intermittent network issues. So I would like to have this capability to launch and hide the app so the user remains connected to the network.

Seems like there is no set command to accomplish this through the command line. Thank you all for your suggestions.