Basically whenever there are command line arguments given to my app (using the box in Run/Run Configurations/Arguments), the Eclipse console will stop displaying the stdout (e.g. prtinf() commands) Is there any way to solve this? Am I inputting the command line arguments in the wrong place? (they are appearing in argv though)
Related
I was debugging in terminal using gdb, and I typed inlayout src,then I entered the UI mode.
Most of the time, it worked fine, but sometimes, the whole terminal text code got mixed.(I post the picture below.).
what's more, sometimes I typed in some shell command in gdb like !pmap <pid>, its output's format was also strange.
I tried to set TERM to screen-256color but it doesn't work.
I solved it in some sense.
I redirect the output of my program to another tty.
I'm writing a C program that requires to hide the characters a user types from the screen during the program execution. For example, when running the following loop
while (1)
{
//do some work
}
the console displays the blinking cursor (that's good). BUT, when the user types keys on the keyboard, these keys are being echoed out to the console. To visualize it better:
Step 1: Starting the program
root#debian:/home/root# ./program
_
Step 2: User types some characters (even though he shouldn't)
root#debian:/home/root# ./program
AdajfsaSJ_
The characters get echoed on the console. How can I stop this? I know it's theoretically possible, but I can't find out how to implement it.
If you need a better example for what I want to achieve, use the screen command on an empty serial port. screen /dev/tty30 for example. This empties the console and runs the program, HOWEVER, the user is not able to enter any characters (there's a blinking white cursor block and no keyboard characters are being echoed to the console). That's what I need.
Any insight would help, thanks!
Use termios() to turn off the ECHO flag of the terminal.
To turn off the text cursor, use the termcap library to control the cursor visibility.
I'm new to code blocks and I'm writing code that takes in a command line input such as a file name, but once I compile and run the Code the console prompts "press any key to continue" like always and I'm unable to type anything in the console? So I can I write in console making my code run.
CodeBlocks will run your executable file without arguments, so you'll probably want to do it yourself. Open a command prompt (cmd.exe) and invoke your program with the desired arguments: C:/path/to/your/project/bin/Debug/program.exe filename.
Alternately you can request the user input via scanf or similar.
Hope it helps!
You cannot pass commandline arguments to your program in the Code::Blocks
console, because Code::Blocks has already started your program when you
see the console. You need to specify any commandline arguments in the
the Project settings before you run it. Then, when the console appears,
your program will be running with the commandline arguments you have
specified.
To specify commandline arguments, select the Project menu on the
top menu-bar of the IDE. In the Project menu, select Set program's
arguments, enter the commandline arguments you want and then OK out.
Once your program is running in the console (with or without commandline
arguments), if it requests any input from the user, then you will be
able to type the required input in the console.
I am debugging a C program with gdb. I have used the tty command to send the output to a new terminal window but am unable to enter input while the program is running.
If I debug in the same window it works fine, but when using a separate terminal window, input doesn't do anything.
I can still kill the process with ctr-c but once I hit the input line, it waits for input and doesn't do anything when I press return.
I have looked around but am haven't found the same problem online. Any ideas?
Start your program in one window. While your program is waiting for input, start gdb in another window. Use the gdb attach command to attach to and debug your program.
My embedded system has one background program which generates some output message to console.
When it's not finished, the login program starts and prompt login string to same console as well.
My question is, when the login prompt string comes out, the output message generated by the background program is not aligned like this:
Embedded System login: msg_line1...
msg_line2...
msg_line3...
The expected output should be:
Embedded System login: msg_line1...
msg_line2...
msg_line3...
msg_line4...
Have no idea how to resolve the problem...
Could anyone help?
THX!!
Configure your terminal program to autolinefeed, so that it generates the \r internally whenever it receives a \n.
use a redirection for your background program
YourBackStuff.sh >/tmp/back_out.1 2>/tmp/Back_out.2 &
or refresh the screen.
Notice that only the appearance is modified, the real output ou current application/shell (so not the background one) is correct, only the terminal show your all the info received. So
YourFrontApp.sh | tee /tmp/front_out.1
cat /tmp/front_out.1
will produce a correct display (when background process stop)
Looks to me like your messages are sent with a new-line character (represented by \n in C) at the end of each line. This requests a new line from the terminal, which it duly provides. It does not request a carriage return (i.e. "go back to the left hand edge"). This would be represented in C as a \r.
To fix it, you need to set your terminal application to interpret \n as \n\r - it will have a setting for "treat newlines as newline+CR" or some such.