i'm aware the it is possible to set the stdin to the content of file defined in the project profile. What i'd want though, is the ability to change the stdin while debugging. Is there any way to do this on a linux system?
Basically i need this because my next input to debuggee is depending on one of it's former outputs. This means i'm unable to set the right stdin content before i start debugging.
In fact i need to set it while i am debugging!
Thank you very much!
Related
What I want to do is to set the default color (like if output \e[0m) for EVERY output. For some reasons I can’t change it in terminal settings and only hope that Bash can
One way I think it might be possible is to redirect output to temporary file (or file descriptor, or function if possible) and print everything char-by-char or something and removing the reset sequence, but I’m not sure it’s the best way
So can Bash or Zsh do it quickly?
Many terminal programs will behave differently depending on the STDOUT destination, either terminal or pipe or file. Usually they will remove colors. There are usually command line options for some of them to keep colors or formatting or anything else that is intended only for direct terminal output. But those options are not always present and it takes time to find them thus I need a generic way to trick the program so that it thinks that STDOUT is terminal, not a pipe. How to achieve this?
There are several tools for this, they basically create a pty for your command.
The best known is probably expect: http://expect.sf.net
Alternatively, empty: http://empty.sf.net
There are several examples in that page, have a look.
For simple cases, script -c 'mycommand' may be a viable alternative.
And tmux, which is powerful and pretty easy to script.
I have a linux installation without X. When I launch a third-part application (i.e. gstreamer) it draws on a portion of the screen, let the users see through the external areas.
I want to "clear" the console so it appears black. Of course the clear command won't work because you still see the prompt.
Might you recommend any way to achieve this?
The environment variable which contains the output displayed by the prompt is named PS1. You can empty this variable when needed.
Don't forget to keep a 'backup' of the value in order to be able to set it back to its old value
It's common to use the command more. more is usually used with pipe. so I think more has the ability to read from stdin. every command separated by pipe is a process, and the one before more just create pipe and dup2 the write pipe to more's stdin. but I found that if I type "more" in the console, just some usages appear. so what is the matter?
Why do you think that anything is wrong? More pages output for the terminal so what would be the point in waiting for enough typed stdin input to page?
If you type more and one or more filenames it will page that input. So the behavior is something like:
am I attached to a terminal? ("isatty")
are there filenames in argv
page files
else
display help
else
page pipe input
It's a feature. It detects that its standard input is connected to a terminal, and displays a help message instead of proceeding. There is hardly a situation where it makes sense to run a pager on input while you are typing it in by hand. If you really actually want to, try cat | more for example.
For what's worth, I looked at the source package provided by the repositories in my linux distribution and found this:
if (!no_intty && nfiles == 0) {
usage(argv[0]);
exit(1);
}
So indeed the behaviour is to display the usage message if no input is detected.
I am writing a console application which is using some library in which (DEBUG) prints are enabled. In my main() application I am taking inputs from user. I want this user input to be separate from my library prints. I cant disable library debug prints. (The problem is library has lots of continuous prints over which it is difficult to take user input. Can I do something like creating a new tty for taking user inputs. )
dup2(2,3p) lets you duplicate an existing file descriptor (such as the one you just opened on /dev/null) onto another existing file descriptor (such as FD2, stderr). So, open /dev/null for writing and clobber stderr with it.
Don't forget to add an option to disable this though, in case you need to debug.