Get command line output on console
apple Verified ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Given a command line command -- could be anything, e.g. 'ls -l'. I would somehow like to run something from the Docker that would execute this command and display it in an alert dialog on the console.
How do I get started on this?
15 replies
Sign in or join Beachball Help to reply.
- 0
Barney-15E ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
How do I get started on this?
Find a terminal/shell app that sends all commands to the logging system.
Log messages (the stuff in Console) are not searched out by Console or the logging system. The messages are pushed into the log by the app that creates them.
- 0
Barney-15E ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
If you are just wanting to send your commands to a log file, you can do that, but I don't know of a way to configure the shell to automatically do that. Some info here: https://serverfault.com/questions/103501/how-can-i-fully-log-all-bash-scripts-actions
This is for Ubuntu, but may give you some hints on what to look for (and it may work on macOS): https://askubuntu.com/questions/161935/how-do-i-log-all-input-and-output-in-a-terminal-session
- 0
markfoley ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
No, I'm not wanting to send messages to a log file. I want to see the output on the console. I used the example of 'ls -l' to try to keep my question simple, but perhaps that backfired. Specifically, I have a command 'apcaccess' that lists information about the state of the battery backup. Run from a terminal window, it displays information like:
APC : 001,038,0981
DATE : 2018-12-12 22:27:30 -0500
HOSTNAME : mpress.hprs.local
VERSION : 3.14.14 (31 May 2016) darwin
UPSNAME : MIKEUPS
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2018-11-12 14:03:09 -0500
MODEL : Back-UPS ES 750
STATUS : ONLINE
What I want to do is create an icon in the Docker the user can click on and have it run that program and send the output to an alert dialog on the console so the user can see it, then close the dialog.
- 0
Barney-15E ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Simplest thing would likely be to create an Automator app or and AppleScript app to run the command and display the output in a dialog. You can run shell scripts in AppleScript, then send the output to a dialog window.
Automator can also run a shell script, but I don't think it has any way to display a dialog except maybe using the Ask for Confirmation.
It could be built inside an Automator App like this:
I'm not sure we are talking about the same Console.
The Console app displays the log files. Logs are created by sending messages to the logging system. There is no "console" short of the Terminal (or another shell emulator). Are you talking about the screen, display, monitor?
- 0
markfoley ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I'm very new to Mac and am trying to integrate a few Mac Minis into our office, so my argot may be off. By "console" I mean the user's GUI desktop/Screen/Monitor -- whatever that's called in the Mac-world. In Linux/Windows it's referred to as the Desktop. Perhaps the same for Mac. Doing 'who' in a terminal session shows GUI users with device 'console'. That's why I'm using that term.
Your suggested Automator script does seem to work for what I want. Thanks, I doubt I'd have figured that out on my own. I've saved that to my Documents folder. Now I'd like to change the icon. I've followed the instruction in https://www.sethvargo.com/replace-icons-osx/ which basically entails copying the icon (.icns) to $HOME/Documents/testAutomator.app/Content/Resources (Documents/testAutomator.app is where I saved the app), and I edited the Info.plist file to make the change:
<key>CFBundleIconFile</key>
<string>battery-power-icon</string>
but that doesn't change the icon. I've logged out and back in. Nada. Suggestions?
- 0
BDAqua ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Yes, we call it the Desktop too. :)
Variously called Finder Also, do a Get Info, CMD+i on it, then...
https://lifehacker.com/5897796/how-to-customize-any-folder-or-app-icon-using-any-image-in-os-x
- 0
BDAqua ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Yes, we call it the Desktop too. :)
Variously called Finder Also, do a Get Info, CMD+i on it, then...
https://lifehacker.com/5897796/how-to-customize-any-folder-or-app-icon-using-any-image-in-os-x
- 0
Barney-15E ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
I would just Get Info on the App and paste a picture into the Icon well. It doesn't change the underlying icon, but puts a custom icon on top of it. Not sure how that would present when run.
For the Battery icon, just set the Finder to display the icon very large and take a screenshot. Cmd-ctrl-shift-4 will give you a selection marquee. Drag around the icon image to copy it to the clipboard. Paste into the Get Info icon well.
Otherwise, I don't know how to make it work.
I use a program called Platypus to bundle AppleScripts and Shell scripts into Apps. It allows you to set a custom icon.
You could just use an AppleScript for the entire thing, and use Platypus to "App"-itize it with your icon. The Full AppleScript is just:
set apcInfo to do shell script "apcaccess" display dialog apcInfo as text buttons {"Ok"} default button "Ok"Oops, I didn't see that BDAqua already suggested pasting an image on the icon.
- 0
markfoley ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Ah ah! I was close. I tried dragging/pasting it to the larger icon image at the bottom of the Info dialog. So, after trying what you said, it just put a generic image of ICNS in there, not my actual .icns file. Perhaps this is because I used Preview to convert a .png to .icns? Next I tried copy/pasting a .icns from /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/, but it wouldn't copy (permissions?). Then I tried manually copying that icon from the /System/.../Resources directory to $HOME/Documents/testAutomator.app/Contents/Resources, naming it as the same name as my original .icns file, but no go. I did log out and back in. In case that made a difference. If I use Finder to navigate to my .app Content/Resources folder, it does show the .icns I copied from the system folder, but it doesn't show in my .app. Advice?
With respect to .apps generally, I saved this to my Documents folder because that's what the default had. Is there a "standard" place to save apps? Documents doesn't really seem like the best place.
- 0
Barney-15E ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
You can create an Applications folder in your Home. That's what I do for things I only use.
Otherwise, you can put your App in the Applications folder for every logged in user to use.
You can't paste an icon file into the icon well as it will just use the icon of the icon file which is a generic system icon. You have to paste a picture into the icon well in Get Info.
- 0
markfoley ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Barney-15E: "You can't paste an icon file into the icon well as it will just use the icon of the icon file which is a generic system icon. You have to paste a picture into the icon well in Get Info."
Again ... Mac newbie here! Please expand. What is an "icon well"? There is a miniature icon at the top of the Get Info dialog with the appname and size. There is a larger icon at the bottom. Is the "icon well" one of these? When you say "You have to paste a picture into the icon well ...", what do you mean? A .png file, not a .icns file?
- 0
markfoley ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
And another question. The app works, but wraps all the text in the output dialog. What is the secret to having each line appear correctly? I could put <br/>s in front of each line if it's looking for HTML (which it's probably not).
- 0
VikingOSX ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
AppleScript's display dialog offers a 'with icon' clause.
If you have the following:
property app_icon : "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/MultipleItemsIcon.icns" display dialog "hi there" with icon POSIX file app_icon as alias returnYou get the following:
- 0
VikingOSX ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
And from the command-line:
apcaccess | osascript 3<&0 <<'AS' property app_icon : "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/MultipleItemsIcon.icns" on run argv set stdin to do shell script "cat 0<&3" display dialog stdin with icon POSIX file app_icon as alias end run ASAnd the output from apcaccess will appear in a display dialog with custom icon.
- 0
markfoley ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Hmmm, your redirected stdin script doesn't seem to do anything after the final "AS", it just sits there, although I see where you're going with this.
After a bit of googling, I found a suggestion to restart the Finder to get the icon to show: 'killall Finder". That worked and my app now shows the correct icon, so I guess I don't need that 'property' solution.
Is your osascript bit supposed to give me the distinct lines of output? I'll play around with that.