Tag Info

Hot answers tagged

61

If the file(s) in question contain really lots of data sending the signal can actually get to cat before it finishes. What you really observe is the finite speed of your terminal - cat sends the data to the terminal and it takes some time for the terminal to display all of it. Remember, that usually it has to somehow redraw the whole output window for each ...


17

When you launch a terminal it will always run some program inside it. That program will generally by default be your shell. On OS X, the default shell is Bash. In combination that means that when you launch Terminal you get a terminal emulator window with bash running inside it (by default). You can change the default shell to something else if you like, ...


16

In Unix, most objects you can read and write - ordinary files, pipes, terminals, raw disk drives - are all made to resemble files. A program like cat reads from its standard input like this: n = read(0, buffer, 512); which asks for 512 bytes. n is the number of bytes actually read, or -1 if there's an error. If you did this repeatedly with an ordinary ...


10

That's because Ctrl+D is a hack. Deep down, Ctrl+D (despite being called the eof character) doesn't actually mean end-of-file: it means “send the pending input to the application now”. This is actually close to the meaning of Ctrl+M (eol), which sends the pending input plus a newline. When you press Ctrl+D immediately after a Ctrl+M (i.e. at the beginning ...


8

The machine in this picture is a (video) terminal, more specifically a VT100 by Digital Research. Decades ago when computers were big, instead of having personal computers for each user, they could have had a terminal, a dummy device with display and keyboard, that is connected to a main computer via a cable. A VT100 is not a computer, but just a keyboard ...


5

The normal solutions for this would be to have started tmux or screen and start the C program from there. You could have attached to that from your ssh ession as well (and disconnect) without disrupting the program. As you started this in a (graphical) terminal and not the console, you could use a VNC viewer to try and look at the current screen after ...


4

On UNIX, a tty (like many other things) appears as a file. Data written to the tty device goes to the terminal and data coming from the terminal is available for reading on the tty. If the tty is a hardware serial port, then data written to it gets sent on the wire and data coming from the wire appears on the tty. If the tty is a machine's video console ...


4

The exact mechanism depends on what shell is running in the "terminal session". For the BASH shell, the man page for "bash" says: MAILCHECK Specifies how often (in seconds) bash checks for mail. The default is 60 seconds. When it is time to check for mail, the shell does so before displaying the primary prompt. ...


4

You are missing your terminal is already running bash (or another shell interpreter) in the first place. A terminal and more precisely a terminal emulator in your case is just a device passing keystrokes to an underlying program and displaying whatever characters are sent to it. While it runs a shell by default, nothings forbids to start a terminal running ...


3

First, you need to find out whether the messages you want are getting sent to stdout or stderr. In your first example, you've got stderr getting redirected to stdout - that's the "2>&1" part. You also have "/dev/null" on the command line, which doesn't entirely make sense. Why does "/dev/null" appear on command line? Second, you need to decide what ...


3

So, as @muru points out in the comments, there doesn't seem to be a simple way to interface the pty created for you with just the shell. I managed all of it but the unlockpt() part. According to something I read here it may be there are some compile-time options in the kernel for disabling newly created pty locking, but I didn't want to do that. So, I did ...


2

This question is a bit old, but I was looking for something similar, and found it here. It creates a second session that shares windows with the first, but has its own view and cursor. tmux new-session -s alice tmux new-session -t alice -s bob If the sharing is happening between two user accounts, you may still have to mess with permissions (which it ...


2

Note that goto was a separate utility, so not part of the Thomson shell per-se. When you invoke the Thomson shell as: sh the-script sh opens the-script on stdin (fd 0) as if you had written sh < the-script instead. The goto command will seek stdin back to the beginning (which obviously if stdin were a terminal and not a regular file wouldn't work) ...


2

This is what tmux option c0-change-interval and c0-change-trigger designed for. You should use a screen manager for resumable session anyway.


2

Terminal Setup I reckon this is more to do with the way the terminal is set up, than with any buffering issue. Check the output of stty -a | grep intr, you should have intr = ^C; on the output line if Ctrl-C is enabled at the tty/pty. If it isn't, you can use stty intr ^C to enable it. Add the line to your .tcshrc or .login to make it permanent (or delete ...


2

may try: gnome-terminal -e "bash -c 'watch sensors'" gnome-terminal -e "bash -c 'gedit /etc/hostname'" gnome-terminal -e "bash -c 'processing /home/Desktop/samudra_gui/samudra_gui.pde'" and start this script from .bashrc or write this in .bashrc


2

Function keys can be interpreted by the window manager or terminal emulator (you'll find that F11, for example, will usually maximize the window) or passed through to the program as VTxxx or ANSI escape sequences. F9 on Linux and Solaris usually sends ESC[20~. Depending on the versions of the software, bash or ksh will interpret this as either 0~ or ~. On ...


2

I don't know what makes you think F9 returning a tilde is "correct", but if you want a tilde, you should use the tilde key. Function keys are mostly undefined, based on the differences in the client-side hardware you are using, the client-side software you are using, the server-side software you are using, and the server-side hardware you are using.


2

OK, you have a couple of options: The option I like best is to rename your ~/.bash_profile with AppleScript: do shell script "mv /Users/YOURLOGINNAME/.bash_profile /Users/YOURLOGINNAME/x" You could also configure Terminal to drop you straight into a root shell, so it won't ask you for the password again after the first time. In Terminal, go to ...


2

Is there any way to undo either of these two commands or to somehow access or unlock my terminal? Reboot into single-user mode: while the screen is still black as it first boots up, hold down ⌘-S. You can let go once the "Apple" screen appears. You will land in an unrestricted root shell, where you can fix things.


2

If you are using the console ttys (/dev/tty1 through /dev/tty7) in text mode you can read the screen buffer directly from the corresponding /dev/vcsN device. You have to know that there are 80 characters per line, so simple maths to convert an (x,y) coordinate to offset (y*80 + x) will get you the desired character. #!/bin/bash # Ranges are 1-80, 1-24 # ...


2

Assuming you want to view the nth line of a file, you could simply do: sed -n '42p' yourfile.py Replace 42 with whatever line number you want to see. After your edit: If you also want to execute this code, simply pipe it to python: sed -n '42p' yourfile.py | python


2

If you're refering to the output of ls, its manpage sent me to the LS_COLORS environment variable and the dircolors helper program that can turn a list of specifications (extensions and the like, including special values like LINK and DIR) into the LS_COLORS you want. dircolors --print-database will give you commented default settings.


1

Avoid running any commands on your host machine originating from a web page. That's a recipe for disaster. Have a look at operating system level virtualization. Depending on your OS you can use zones, jails or LXC. Those OS level instances have a very low overhead and can be fired up pretty quickly. They do provide separation between the host OS and the ...


1

Mail sent by cron is often considered a spam and called cram (cron spam). It is indeed not useful to receive notification every time command was run and succeeded but it would be good if cron still informed you about errors. You can cronic for this purpose: Cronic is a small shim shell script for wrapping cron jobs so that cron only sends email when an ...


1

Edit .bashrc Or .bash_profile. http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_01.html


1

If you think that you can cause the event by a specific action or interaction, by far the simplest method is something like: watch -d -n1 "stty -F /dev/pts/106 -a | grep -Eo '.(icanon|ixon)'" Run this on a new terminal, the option to -F is the terminal you will run the program on (run tty to see what it is before starting it). Omit | grep .. if you want ...


1

Unless you use the mostly experimental support for full RBG-colors in some terminals, you're limited to the indexed 256 color palette provided by the terminal. You're right that terminals may slightly deviate in the exact colors used, and that will be noticeable. If you completely reassign colors (turn red into blue etc.), there's nothing that corrects this ...


1

I guess this has something to do with a font. In text mode different fonts are used than in X. Doing a simple googling says that it might be not possible to achieve in text mode Arch Linux forum and LFS Console


1

You could use wmctrl to tell the window manager to activate it (raise it and give it focus): wmctrl -ia "$WINDOWID"



Only top voted, non community-wiki answers of a minimum length are eligible