Programming :: Stuffing A Key Into Another Virtual Terminal's Stdin?
Oct 20, 2010
I want to put a keystroke into another virtual terminal's stdin.A simple 'echo p > /dev/tty7' causes a p to appear on the console of tty7 but not the app running in tty7 to respond as though a p key had been pressed. Per the instructions of a fellow in the software forum I tried using an ioctl, but that returned a permissions error, even when I made the target VT's permissions 777 (and it had the same owner).
View 1 Replies
ADVERTISEMENT
Oct 19, 2010
causes a 'p' to appear in tty7 but not the program running in 7 to react as though a 'p' had been pressed.
View 12 Replies
View Related
Jun 28, 2010
Is it possible to redirect stdout and stderr from one terminal say /dev/pts/2 to another /dev/pts/3?
I tried the following:
Code:
/dev/pts/2 2>&1 /dev/pts/3&
Then when I run a command the process stops.
View 4 Replies
View Related
Jun 22, 2010
Often in bash we read lines from stdin in a loop and implicitly discard the remaining stdin by terminating the loop. Is it possible to discard it without terminating the loop? It could lead to smaller code.
Here's an example which uses two loops and below is the same algorithm assuming unwanted stdin can be discarded
Code:
found=
while read destination gateway _
do
[[ $destination = default ]] && found=yes && break
done <<< "$( route )"
[Code].....
View 12 Replies
View Related
Mar 14, 2010
I have a small program that reads stdin from a pipe using fgets. Now fgets blocks for the first line but after that it will not block.
The code, my_echo.c -
int main(int argc, char **argv) { char buf [2000] ;
char* pc ; printf("hello ") ; while (1)
{ buf[0] = (char) 0 ;
pc = fgets(buf, sizeof(buf), stdin);
if (pc != NULL) printf("%s ",buf); } return 0; }
How its called
* In terminal window 1: ./my_echo < my_fifo
* In terminal window 2: echo "1234" > my_fifo
* In terminal window 1: prints hello then 1234.
* Checking with ksysguard or top shows that my_echo is consuming 40% of CPU time.
Adding a few printf's shows that the gets is not blocking and returns a null pointer.
* In terminal window 2: echo "qwerty" > my_fifo
* In terminal window 1 qwerty prints.
I want a read function that does in fact block so my program does not tie up CPU time, read does not block.
View 7 Replies
View Related
Dec 15, 2008
I need to write a script which will get a number from STDIN and then with that number echo a set number of questions (its for a firewall config). Heres what I want the user to receive.
How many ports do you want open? 3
1. specify port: 80
2. specify port: 21
3. specify port: 23
In the background this will echo a command out to a text file which will read as follows:
open port 80
open port 21
open port 23
I've done this before but I've completely forgotten how
View 2 Replies
View Related
Oct 10, 2010
[code]...
I've given the output from `df` on AWK's stdin. But what I wonder is if there's a way to get AWK to run `df` itself, produce the same output, and exit? Doesn't seem to be that simple. Here's some examples: Works for some reason, and I think only in Bash (nothing is required in the $()
[code]...
does AWK absolutely need *something* on stdin, before it begins to process the data? Can it be made to open a file or stream internally, act upon that as though it were the stdin, and exit?
View 14 Replies
View Related
Aug 18, 2010
I'm trying to write a shell script that do ftp and download file periodically, this script should be called by a daemon running in the background.
the shell script "script.sh" is as follows:
Code:
yafc ftp://test:test@192.168.1.225:21 < commands
and the "commands" files is
Code:
d Root/md5* /
quit
if I run script.sh it will work just fine. But when the daemon software calls the "script.sh", the script will send ftp login request to the ftp server, but will not even answer the username or anything.
I believe it is something about child process redirection, but I don't know how to deal with it.
This problem is not only with yafc, it is the same with any ftp client or any application like telnet and so.
View 4 Replies
View Related
Apr 28, 2010
I am trying to read one line at a time in perl and not wait for stdin eof to start the action:
Code:
foreach(<STDIN>){
<do something>
}
if i pipe ls into it, it waits for ls to be done before doing the action.
View 1 Replies
View Related
Nov 24, 2010
I'm trying to write a program that will fork a series of FTP sessions. For each session, there should be separate input and output files associated with stdin and stdout/stderr.
I keep reading how I should be able to do that with dup2() in the child process before the execl(), but it's not working for me. Could someone please explain what I've done wrong? The program also has a 30-second sniper alarm for testing and killing of FTPs that go dormant for too long.
The code: (ftpmon.c)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
[code]....
The output:
$ ftpmon
Connected to gila-crstest.gilacorp.com (172.16.20.8).
220 (vsFTPd 2.0.1)
ftp> waitpid(): Interrupted system call
Why am I getting the ftp> prompt? If the dup2() works, shouldn't it be taking input from my script and not my terminal? In stead, it does nothing, and winds up getting killed after 30 seconds. The log file is created, but it's empty after the run.
View 3 Replies
View Related
Aug 8, 2010
I'm working on an application used for backup/archiving. That can be archiving contents on block devices, tapes, as well as regular files. The application stores data in hard packed low redundancy heaps with multiple indexes pointing out uniquely stored, (shared), fractions in the heap.
And the application supports taking and reverting to snapshot of total storage on several computers running different OS, as well as simply taking on archiving of single files. It uses hamming code diversity to defeat the disk rot, instead of using raid arrays which has proven to become pretty much useless when the arrays climb over some terabytes in size. It is intended to be a distributed CMS (content management system) for a diversity of platforms, with focus on secure storage/archiving. i have a unix shell tool that acts like gzip, cat, dd etc in being able to pipe data between applications.
Example:
dd if=/dev/sda bs=1b | gzip -cq > my.sda.raw.gz
the tool can handle different files in a struct array, like:
Code:
enum FilesOpenStatusValue {
FileIsClosed = 0,
FileIsOpen,
[code]....
Is there a better way of getting the file name of the redirected file, (respecting the fact that there may not always exist such a thing as a file name for a redirection pipe).
Should i work with inodes instead, and then take a completely different approach when porting to non-unix platforms? Why isn't there a system call like get_filename(stdin); ?
If you have any input on this, or some questions, then please don't hesitate to post in this thread. To add some offtopic to the thread - Here is a performance tip: When doing data shuffling on streams one should avoid just using some arbitrary record length, (like 512 bytes). Use stat() to get the recommended block size in stat.st_blksize and use copy buffers of that size to get optimal throughput in your programs.
View 4 Replies
View Related
Sep 7, 2010
I'm writing a script to execute bash commands in the PHP CLI. I would like to suppress errors from bash and write my own error message if an error occurs. So far I have this (assuming log.txt doesn't exist!):
Code:
tac log.txt 2>/dev/null
Which works as expected, tac kicks up an error but the error is suppressed, but when I use this:
Code:
tac < log.txt 2>/dev/null
I get:
Code:
bash: log.txt: No such file or directory
The tac error is suppressed but bash still gives me a dirty error.
View 2 Replies
View Related
Jan 8, 2010
Code:
#!/usr/bin/perl
use 5.10.0;
use strict;
use warnings;
use Net::Ping;
[code]....
View 1 Replies
View Related
Nov 2, 2010
If I enter my first virtual terminal with ctrl + alt + F1, how would I get back to my GUI.
View 7 Replies
View Related
May 6, 2011
Metacity can be locked, but what about a logged-in session in a virtual terminal?
View 3 Replies
View Related
Dec 30, 2015
I am a newer to debian. I want to change the color of the vitrual terminal. I have found the function " setvtrgb ",but I don't know how to mix the color , Only text green and background black...
View 10 Replies
View Related
Feb 9, 2010
I'm running ubuntu 9.10 on a Dell XPS M1530. Sometimes i get a _VERY_ loud beep-sound, eg when i run out of battery or, the case that has me coming here when i'm working in a virtual terminal (tty1-6) and hit backspace once too often, that is, when the command line is actually empty.Not that big of a deal you might think, but, especially when you're wearing good (read: possibly loud) headphones the experience is that god damn unpleasant that i'd like to make sure it won't happen again.Oh and well, just hitting mute (in gnome, which doesn't have a lot to do with tty1 anyways) won't do the job.
View 2 Replies
View Related
May 27, 2010
I imagine I'll have to install something, but Google has shed no light for me thus far. And just to clarify, when I say virtual terminal I mean the terminals accessed by CTRL+ALT+(F1-F6). I'm going to be doing a challenge/learning experience where I don't allow myself a graphical interface for a month. way around BASH through adaption. However, if I have to go a month without music I will go insane.
So, even if this is possible can I listen to music from the internet (....., playlist.com, etc.) or just music on my hard drive? And I'm not sure if this thread belongs in Desktop Environments or not, that section seemed to focus on graphical interface.
View 9 Replies
View Related
Aug 20, 2010
I cannot have any more than 47 characters on each line of my virtual terminal without everything on that line disappearing. The text is apparently still there, since commands that need more than 47 characters still work but the text stays hidden. After the text has been overlapped I can type as many characters as I like and it no longer overlaps, but my PS1 on that line and all previously overlapped text stays hidden.I'm almost certain that the problem is in my bash configuration since it happens in a terminal emulator as well as the virtual terminal.
View 2 Replies
View Related
Apr 1, 2011
How to change the resolution of a VT, but nothing on how to find out what it is?
So what is it?
Code:
outputs (for example)
Code:
View 1 Replies
View Related
Jan 10, 2011
My emacs 23 is running on Ubuntu 10.04 and I am very a emacs primer. in virtual terminals, how can I remap keys to swap the right alt key and the right ctrl key automatically every time the machine starts up? But how to swap Alt and Ctrl on the right side?
View 3 Replies
View Related
Jul 28, 2011
I am new to slackware, but not new to linux. I recently installed slackware 13.37, and am enjoying it very much so far. The most annoying problem I currently have is that, after starting X, I cannot switch to a virtual terminal or even end X without having a problem. For instance, from the GUI if I hit ctrl-alt-F1, instead of going to the 1st virtual terminal, the screen fades quickly to black and does not return. I have not been able to make any progress on this problem, so any input would be greatly appreciated.The only thing worth noting really is that I'm using Fluxbox as my default window manager. Other than that I haven't done a lot of modifications to the base system other than installing some basic packages, but I had this problem since booting directly after installation of the os.
View 14 Replies
View Related
Feb 19, 2010
When I try to go to a virtual terminal from X the writing is too dim to read. When I boot to run level 3 all is fine, then I "startx" and use the gui. If I "ctrl-alt-F3" the printing on the screen is so dim that I can't see it. Is there a setting for this somewhere that I haven't found. Before installing Slackware 13-64 I ran Zenwalk for over a year and never had this problem.
View 2 Replies
View Related
May 17, 2009
How do you increase the text size in the virtual terminal (the one you get to when you press ctrl+alt F1-6)? My monitor is pretty old and kind of small, so I need the bigger text size to really be able to use it at all. I tried to find the answer in google, but I couldn't find the answer. I found answers for suse and ubuntu and tried to use those. They said to edit part of the boot loader config file, but I couldn't find a similar line in the grub.conf file. And I don't want to play with it without knowing what I'm doing.
View 14 Replies
View Related
Mar 26, 2010
I've been trying to stop kdm the normal way, switching to a virtual terminal with ctrl+alt+f1 and using:
Code:
I've done it this way in other distro's and it's always worked.
How do I stop/start kdm from a virtual terminal in Suse ?
View 5 Replies
View Related
Feb 5, 2010
I recently installed Fedora 12 for some Linux testing. When I switch between virtual terminals (CTRL-f1 Ctrl-f2) I can no longer scroll back in the VT I left and came back to. Any new data created will be scrollable, but i can never get back to before the switch. I'm sure this used to work (several years ago). Was this introduced as a security feature to prevent left over data on VTs from being seen by the wrong eyes? If so, is there a way to get the old functionality back?
View 1 Replies
View Related
Feb 10, 2010
It does in jaunty.....
Code:
00:00.0 Host bridge: Intel Corporation Mobile PM965/GM965/GL960 Memory Controller Hub (rev 0c)
00:01.0 PCI bridge: Intel Corporation Mobile PM965/GM965/GL960 PCI Express Root Port (rev 0c)
00:1a.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #4 (rev 02)
00:1a.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5 (rev 02)
00:1a.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2 (rev 02)
00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 02)
00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1 (rev 02)
00:1c.1 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 2 (rev 02)
00:1c.3 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 4 (rev 02)
00:1d.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3 (rev 02)
00:1d.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1 (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev f2)
00:1f.0 ISA bridge: Intel Corporation 82801HEM (ICH8M) LPC Interface Controller (rev 02)
00:1f.1 IDE interface: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller (rev 02)
00:1f.2 IDE interface: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA IDE Controller (rev 02)
00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller (rev 02)
01:00.0 VGA compatible controller: nVidia Corporation G84 [GeForce 8600M GT] (rev a1)
03:00.0 Ethernet controller: Broadcom Corporation BCM4401-B0 100Base-TX (rev 02)
03:01.0 FireWire (IEEE 1394): Ricoh Co Ltd R5C832 IEEE 1394 Controller (rev 05)
03:01.1 SD Host controller: Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter (rev 22)
03:01.2 System peripheral: Ricoh Co Ltd R5C592 Memory Stick Bus Host Adapter (rev 12)
03:01.3 System peripheral: Ricoh Co Ltd xD-Picture Card Controller (rev 12)
0c:00.0 Network controller: Broadcom Corporation BCM4312 802.11b/g (rev 01)
View 3 Replies
View Related
Apr 17, 2011
In a shell script. And use that in a condition.
Something like:
Code:
if(pts) echo "emulated"
if(tty) echo "virtual"
View 3 Replies
View Related
Apr 17, 2011
I put
Code:
echo -e 'e[0;34m'
into /etc/profile, but it still doesn't work until I login. I'd like it to work before that, so that all messages (like those displayed on boot up) have these default settings.
View 6 Replies
View Related
Dec 3, 2010
How do I increase the font size on a tty. I have googled it and still don't have a Slackware way of doing it. What /etc file needs to be edited?
View 1 Replies
View Related