Tell Mac .app bundle to open command line window - macos

Is there a way to tell a Mac .app bundle to open the command line for the purpose of printing to stdout? I think it does not really matter, but it is a C++ Qt app.

No, there's no way to do that.
An app can launch Terminal.app or similar and make it open a window, but that window won't display the output of the app. The stdout of an app isn't connected to any "command line" or Terminal window or anything. Basically, it's a file descriptor opened to /dev/null. You could re-open it to some other destination, but none will be a command line or Terminal window unless you build it to be so.

Related

tkdiff from terminal on mac opens in dock instead of window

I followed the instructions here:
How to run TKDiff from the terminal on mac os
to get tkdiff working from terminal in mac os. The problem is when I run "tkdiff file1 file2 " on the terminal it does not open up a window. Instead, app Wish appears "hidden" in the application dock and I have to click on it in order to display the diff window. After clicking on it everything is fine. But I'd rather the diff window to pop open as soon as I run tkdiff. Anyone know if there is a setting I need to change, or if I'm doing anything wrong?

Terminal window with running command

Is it possible to start a new window of terminal as in Windows: start example.bat? It opens a new window and runs an command.
You can do this using the open command, or ossascript. Here are some related questions using those commands in their answers:
Programmatically launch Terminal.app with a specified command (and custom colors)
Running a command in a new Mac OS X Terminal window
What arguments does the Mac's Terminal.app accept?
The open command is more straightforward, allowing you to specify the name of a script or command to be run, as noted in one answer. That describes this case (referring to open(1)):
open -a Terminal.app file
where file is the application to be opened. You may have to give its full pathname. The manual describes also a --args option which it states can be used to pass parameters to the application.

Emacs editor "locks" out terminal when being used

The issue I am having is when I open a file via emacs it will open another window in the emacs text editor, but lock out the terminal. What I mean by lock out is that the terminal seems to be linked to the window of emacs that had opened up. When I first downloaded the software I did not have this issue and was able to open multiple emacs windows at once but now I have to close out of the current emacs window to open another. Any suggestions on fixing this?
It sounds like you want to have the file pop up in a window when you open it, rather than fill the whole terminal.
If that's the case, you should
install a graphical version of Emacs from http://emacsformacosx.com/
put alias emacs=/Applications/Emacs.app/Contents/MacOS/Emacs in you ~/.bashrc
open files with emacs file.txt &. The file will open in a separate window and you can keep using your terminal

Lazarus on Windows: Why the extra terminal window?

I built a Lazarus GUI application using Ubuntu and then took it onto Windows to compile. On Ubuntu I run it from the terminal like this:
./prg arg
It runs fine using the argument arg passed to it. On Windows this is what I did:
Create shortcut to exe
Edit shortcut and include the argument.
To run on Windows, I run the shortcut.
It works fine but there's an additional terminal window opening behind the application, when I run the shortcut. When the application exits, the window closes with it. The terminal window is empty.
On Windows, before compiling I had to uncheck the -WG switch in compiler options. This was because althought the app is GUI-based, there is a simple routine that checks for the argument passed at command line and uses Writeln to output a message if there were errors.
My key question is why is this terminal window coming up on Windows and how do I get rid of it or suppress it?
Thanks!
(1) Make sure you have set {$APPTYPE GUI} in your code. Otherwise there will be always a "terminal" opened on windows.
(2) Maybe you are confusing a "real" shortcut (*.lnk) with cmd/batch file? The latter also opens a terminal that dies when the lauched app closes.

Terminal app in Mac OS X Lion 10.7 stuck?

Some days ago I tried to create a shell script which would open all the torrents files in my downloads folder. I am not sure if I get the sh file written right, since then I am getting this message:
Last login: Fri May 18 22:54:28 on ttys000
LSOpenURLsWithRole() failed for the application /Users/Alex/Downloads/(Demonoid.me)-Adobe_Master_Collection_CS5_(OS_X)__12302562.8934.torrent
with error -10810 for the files
/Users/Alex/Downloads/Coda_1_6_2_[_Plist]_[Serial]_O-Demonoid.me-O_12302562.8934.torrent,
/Users/Alex/Downloads/Coda_1_7_3_[k'd]-((Demonoid.me))_12302562.8934.torrent,
/Users/Alex/Downloads/[kat.ph]grid.systems.in.graphic.design.josef.muller.brockmann.torrent,
and /Users/Alex/Downloads/[kat.ph]pixie.lott.cry.me.out.mp3.housezz.torrent.
job done
/bin/bash: line 8: end: command not found
[Process completed]
And I can't do anything in Terminal. I don't know what to do. Any insights about it?
Open a terminal and let it hang.
Open the terminal preferences menu (Command-comma).
In the Startup tab, remember your current shell setting.
Choose a shell other than Bash or Sh (e.g. /bin/tcsh — this is a desparation measure, and only temporary).
Close the locked terminal.
Open a new terrminal (Command-N).
That should give you a command prompt.
In that window, edit your .profile or .bashrc or whatever you added the Torrent lines to.
Remove the Torrent-related lines.
Go back to terminal preferences.
Reset the shell to /bin/bash.
Try opening a terminal window once more.
When it comes to trying to add the Torrents again, write a shell script. Debug it. Only put it in your profile when you're sure it is correct, stable, reliable, and doesn't lock your terminal. Then test it with a terminal already open — opening a new terminal to do the test. You've then still got an unlocked terminal you can fix problems with.
If you have a graphical Vim (Gvim or MacVim), you may be able to launch that and then edit your .profile without having to tweak the Terminal preferences.

Resources