How to use backspace in UnetStack Shell? - unetstack

Whenever I use backspace in Unet shell the cursor moves forward instead of erasing the line.Is there some other way to use backspace in unet shell ?

Bug fixed by PR 176. Will be part of fjåge release 1.9.0, but available today from the dev branch of fjåge, if you need it.

Related

How to enable logging in xterm

Is it possible to turn on logging feature by default in xterm?
Lets say for example, I have example program in c that give an output in xterm everytime i ran the program from default bash terminal in linux. And I want to save the output that shows in xterm into a file everytime the programs is run.
I'm using centos7_x86_64 fyi
Thanks.
In Windowmaker:
Hold down ctrl + left click in xterm window (on the terminal text), click on "log to file".
A cool thing to do is when you're coding, log the terminal, and then when you cat the Xterm log, you see coding in fast forward. If you wanted you could video it.
Note that there are also other menus in xterm, accessible using Ctrl+Left Click, Ctrl+Middle Click, Ctrl+Right Click.
Log file will be in the directory that you launched Xterm from, and will be in the format: Xterm.log.<hostname>.<date>.<time>.log.
This is a very good question, there's no reason to mark down a question like this.
It can be done in two ways:
Using script:
xterm -e script mylogfile -c "someCommand -i input_file -o output_file -f someArg"
Redirect to a file:
xterm -e 'someCommand --arguments 2>&1> /path/to/mylogfile'
I do essentially this with "terminal-window", mrxvt, "hcm" and "pypty".
terminal-window wraps mrxvt, just filling in some commandline options. mrxvt is a lightweight, multitabbed, nonunicode terminal emulator not dissimilar to xterm.
hcm is a GUI that makes it easy to run a shell (or other command) on a remote host. It can also start an mrxvt with remote ssh's without requiring the GUI if you prefer (using hcm-term).
pypty is a /usr/bin/script reimplementation that is written in Python. It is not significantly different from /usr/bin/script, except it gives a "dated files mode", that allows you to have one file per pseudo terminal per day. So if you leave a shell logged in overnight, you get one file per day - this tends to make it easier to find what you're looking for.
All this combines to give you pseudo terminal logging with great ease. Commands are run on remote hosts, but logged locally. Just start a "fancy terminal-window" (or use hcm-term), and everything you see on the screen plus control characters (but not nonechoed passwords) will be logged under ~/.hcm/logs/<year>/<month>/<day>/* .
Also, if you hit the shell button in the lower right of mrxvt, you get another ssh session into the same remote host, which is also logged locally (to a different file under ~/.hcm/logs/...). When I started making use of that feature, I had no idea how much I would grow to like it.
You can obtain them from http://stromberg.dnsalias.org/~strombrg/hcm/ There's a video there that shows how easy it is to set up and get started with.
BTW, fancy terminal-window sets up $PS0 or "trap DEBUG" to give you command start times and finish times. It's great for post mortems. It does this without replacing any of the usual bash startup files.
I wrote terminal-window, hcm and pypty, but I can't take credit for mrxvt. :)
HTH

sending EOF to stdin in Clion IDE

Is there a way to send EOF to stdin when running a c program in Clion IDE?
I tried ctrl+D - it simply shuts the program down.
Ctrl+Z doesn't work either.
Any ideas?
BTW - I'm using it on a Windows 10 OS.
ctrl+D does the job, however there is a known problem, to avoid it disable option run.processes.with.pty in Registry (Find Action > Registry).
Type in ^ on a newline, in the console after your input, I found it does the trick.
Another option is to run the program from command line, and attach to it from CLion.
In that case, you'll have your native shell.
It's detailed at
https://blog.jetbrains.com/clion/2016/01/attach-to-local-process/
The process is very simple - after running the program from command line, choose Run->Attach to Local Process...
And choose your program from the list. You can type in the search field.

Can i make a pc password lock system with batch file?

I made an alphanumeric password checker using one-by-one char inputs via choice command.
I was to register it to start programs and lock my pc.
But it cannot catch CTRL-C terminating.
Piping echo N solution did not help me
because it recieves keyboard inputs.
How do i prevent users from typing CTRL-C?
Found this site: Dos Tips
The solution that I found to block CTRL+C aka Terminate Batch Y/N COMPLETELY.
No Fuss, No kidding, No Breaking Out. XOUT but that too can be disabled.
Briefly:
Code:
C:\PROFILES\ADMIN>REN "%COMSPEC:~0,-8%\CSRSS.EXE" !!!CSRSS.!!!
OOPS Windows File Protection. If WFP is enabled ask almighty Google about that.
Transpose the file names to undo. WARNING: This MAY also break your toaster. 8)
PRO: Disallow all programs from injecting code via CSRSS hooking.
CON: PROPERTIES from the System Menu of CMD Windows are disabled as well.
CON: Enemy Territory will certainly whine until dialog box is dismissed once.
ELSE This is bulletproof. I'm being extremely terse!
I would recommend reading the other page and some of the info on it before you run the script as it could be damaging. If you have a VM to test it on that would be best :)

Why does the terminal show "^[[A" "^[[B" "^[[C" "^[[D" when pressing the arrow keys in Ubuntu?

I've written a tiny program in Ansi C on Windows first, and I compiled it on Ubuntu with the built-in GCC now.
The program is simple:
read the line from console with scanf().
Analyze the string and calculate.
But something weird happens. When I try to move the cursor, it prints four characters:
pressing Up prints "^[[A"
pressing Dn prints "^[[B"
pressing Rt prints "^[[C"
pressing Lt prints "^[[D"
How can this be avoided?
Why does it print these 4 characters instead of moving the cursor?
Because that's what the keyboard actually sends to the PC (more precisely, what the terminal prints for what it actually receives from the keyboard). bash for example gets those values, deciphers them and understands that you want to move around, so it will either move the cursor (in case of left/right) or use its history to fetch previous commands (up/down). So you can't expect your program to magically support arrow keys.
However, reading from standard input from the terminal already supports left/right arrow keys (I believe, but I'm not in Linux right now to test and make sure). So my guess is that there is another issue interfering. One possible cause could be that one of your modifier keys is stuck? Perhaps ALT, CTRL or SUPER?
For those who are coming from the osx (mac) try changing the shells to bash
Terminal -> Preferences -> Shells open with -> [select] Command (complete path)
then paste
/bin/bash
This might be because the user account is created in shell. You can change it to bash by two ways.
Permament solution is -
sudo chsh -s /bin/bash ${username}
To get this solution working you will have to logout and login
Temporary solution is everytime when you login into the ubuntu server type bash and hit return.
If it's under a docker container, run /bin/bash . This helped me solve the problem.
Additionally to what Shahbaz mentioned, I realized that pressing enter (thus sending an empty command) can fix the problem. This is usually necessary after using CTRLC to cancel a command.
On MacOS Terminal for me was enough to uncheck "Scroll alternate screen" for the issue to disappear. See screenshot of the preferences below.
You can (re)bind keys. Add this at the bottom of your .profile, .zshrc or whatever shell config you have.
bindkey -e
bindkey '\e\e[C' forward-word
bindkey '\e\e[D' backward-word
i think simple way is we can just do
kill %%
because this sometimes happen because of background processes.

Capturing the effects of SetConsoleTextAttribute when redirected through a Pipe?

I've redirected stdout of a child process spawned with CreateProcess to a pipe. It works fine except that, as far as I can tell, no information about color changes are coming through. The child process is using SetConsoleTextAttribute to change the text color--is it possible to detect this through the pipe and, if so, how?
I'm ultimately displaying the output in a RichEdit control and I would like to capture the color information if at all possible.
This is in C with the Win32 API on XP and Vista.
You probably need to use ReadConsoleOutput (and/or related ones) found here: http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx.
Hope that helps.
There maybe a work around...its old and not-used much!
Use Ansi.Sys and load that.
Whenever you output a text to the console, by using the Escape sequence, you can set a color around the text.
Then parse the escape sequences into the equivalent for RichText Colors.
The escape sequences are standard here. Here is how to add support for ANSI.SYS into the console. And here is the official KB from Microsoft on how to do this.
For an example:
printf("\x1b[33;43Yellow on Blue\x1b[0\n");
Now, parse the bit after the \x1b[, 33 is yellow foreground, and 43 is blue background, then look up the relevant color for that and set it in the RichTextBox..
Note: \x1b[0 turns off the attribute.
Edit: This may not be the best solution as that's for legacy NTVDM's 16bit DOS command.com under XP or later. But however, I found another link to 'ansicon' here which is for pure cmd.exe 32bit console, with ANSI support.
Hope this helps,
Best regards,
Tom.

Resources