General :: Redirect Stdin And Stderr To Another Terminal?
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
ADVERTISEMENT
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
Jun 3, 2011
I have several commands in a bash script, and in the middle of the script there are several commands whose output and error streams I want to redirect to a file. I think I could simply add '>> myfile.txt' to the end of every command, but is there a way to set it before that block of commands, then reset the streams to their original state at the end of that block?
View 1 Replies
View Related
May 12, 2009
I have a little complex Makefile system. A parent Makefile call dozens of Makefiles in subdirctories. And the subdirctory Makefile calles shell script to do real building. I want to grab all output this Makefile system generate. So, i employ "make 2>&1 > make.log". but not all output messages are filed into make.log. The message generated by sub-makefile called shell script cannot be recorded into make.log. And another curiouse thing is, if i launch "make 2>&1 > make.log" in a perl script, all output do be sent into make.log.
View 2 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
Dec 14, 2010
hello
I tried to find a good subject but it was the best of mine, anyway I'll explain it here.
some time I do some thing like installing a new application in Linux terminal of my office PC but it take a long time and I have to go home during its installation or configuration process that it is not good to cancel it.My current solution is abandoning the process until next day. I wanted to know is there any way to redirect an input and out put of a terminal to another one, if it works I can continue my abandoned process by ssh to my Linux office PC and redirect that terminal to my new remote sshed terminal from my home.
Thank a lot for any help.
View 4 Replies
View Related
Jul 27, 2010
Can I use qDebug() to print out stderr messages? If I just use qDebug() << stderr; I get hex output.
View 1 Replies
View Related
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
View Related
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
May 26, 2010
I have sshed into a linux box and I'm using dvtm and bash (although I have also tried this with Gnu screen and bash). I have two terminals, current /dev/pts/29 and /dev/pts/130. I want to redirect the input from one to the other.And then when I type in /dev/pts/29 the characters I type should show up in /dev/pts/130. However what ends up happening is that every other character I type gets redirected.
View 2 Replies
View Related
Apr 17, 2010
i have a process launch by another app, i want to see the output (that is in console) in a terminal (gnome-terminal or tty); how can i capture de standart I/O from a process. my process (aria2) is launch by firefox and the output of ps is like:
# ps aux | grep aria2
dorian 30289 2.8 0.1 12148 4048 ? D 07:08 0:03 aria2c --continue -d /home/downloads/so/suse --referer=http://software.opensuse.org/112/en
...is running but i cant see the output (download state), how can i capture or redirect standart I/O to my terminal to get something like the output of:
$ aria2c --continue -d /home/downloads/so/suse --referer=http://software.opensuse.org/112/en --load-cookies=/tmp/flashgot.h2fnxf84.default/cookies --input-file=/tmp/flashgot.h2fnxf84.default/flashgot.fgt
[#1 SIZE:6.7MiB/4,289.3MiB(0%) CN:5 SPD:25.3KiBs ETA:48h01m01s]
View 1 Replies
View Related
Apr 20, 2010
I have a script where I want to redirect stdout to the terminal and also to a log file aswell as redirecting stderr to the same log file but not the terminal.I have the following code which I found on the net which redirects both stderr and stdout to a file and the logfile,
Code: if [ -p $PIPE1 ]
then
rm $PIPE1
[code]...
View 3 Replies
View Related
Oct 1, 2010
this might be an interesting one for the bash scripting gurus. I seem to break my teeth on it. The mission:- do a dd over ssh to trasnfer an image to another host- capture the dd PID on the other side- send a USR1 kill signal to it- capture that output on the original host It goes wrong on the last part. This is what I have before that step:dd if=image.gz | gzip -d | ssh host2 "dd of=/dev/vg1/lv1" &PID=`ssh host2 ps aux |grep dd|grep lx05|awk '{ print $2 }'`when I do "ssh host2 kill -USR1 $PIDI get nice outputs to the screen. When I replace the first line with:dd if=image.gz | gzip -d | ssh host2 "dd of=/dev/vg1/l01 2>/tmp/output.txt" &the dd command seemd to die. I suspect a problem with the pipe, since this does work when executing locally on a host without piping.
View 4 Replies
View Related
Dec 1, 2010
I have seen a post where someone was explaining the virtuality of stdout and stderr and that it can be redirected with e.g. 2>file.txt but this apparently is not working for me!
I have a CUPS filter with fprintf(stderr,...)
View 5 Replies
View Related
Jul 6, 2010
Is there one command that will let me record an entire terminal session (with any possible errors) to a text file while also seeing all output on screen too? I know it can be done for individual commands, but I'm looking to do this for an entire session where the individual commands will be normal (i.e., not piped into tee, etc.). It would be even better if the command prompt is captured too. The obvious utility of this makes me think someone surely has come up with a solution long ago (probably in the 60's).(I'm sure it goes without saying, but subsequent output in that session should be appended to the file. The file should contain the full history, with all output and errors, of the session.)
View 9 Replies
View Related
Sep 26, 2010
I execute an application from a script file and redirect stdin to it from here-doc like this:
my_cli << HERE_DOC
enable
configure
10
exit
exit
HERE_DOC
This works as expected, but I don't see neither the input nor the app output. The application is an interactive prompt written in C. When I interact manually with it, I see the prompt itself and responses to my input, but when I execute the aforementioned script I see nothing. I would like it to print the input and the output as if a real user was typing. Do you know how to achieve that?
View 3 Replies
View Related
Apr 28, 2011
I have the following bash script:
#do some time consuming task here read -p "Give me some input: " input
Now as you might've guessed, if users press some random keys during the "time consuming task," they're read into input as well. how do I clear stdin (or at least ignore it) before I issue the read command?
View 1 Replies
View Related
Jul 28, 2010
I am trying to write input to a shell and get the shell to parse the input that I am writing to it as if a user was typing in commands.
Thus far I have tried echoing some text into the shell's FD for STDIN in /proc/<pid>/fd Whilst this displays the text that I echo, the shell that I am writing to never tries to execute the command that I pass to STDIN. What is the difference between a shell taking STDIN from the user and data written to STDIN by another process e.g. echo ? It appears I am missing something fundamental.
View 5 Replies
View Related
Aug 5, 2011
Am having issues getting the output from a script to be logged in a file. I need the script to output both the stderr and stdout to the same text file.
At present I have the following script:
Code:
#!/bin/bash
echo TR3_1 > printers.txt
snmpget -v 1 -c public 10.168.**.* SNMPv2-SMI::mib-2.43.10.2.1.4.1.1 &>> printers.txt
[Code].....
View 4 Replies
View Related
Nov 22, 2010
I need to achieve a particular effect using bash's redirection facilities.I know that I can redirect a file to some program's standard input:[user@host]$ application < file.txtThe thing is, I'd like to know can I regain control of this program's input after the file content's have been passed to it. In other words, I'd like to run a command similar to the above, and then, instead of the termination of the application, I'd want it to wait for further commands from standard input (keyboard).
As I write this question, it occured to me that I could probably write another application (or a script), that would at first write some data to standard output and then act as echo, like:[user@host]$ stdin_proxy.sh | applicationWould it work, and is there any better way to do so? There are a bunch of Googleable tutorials covering this issue, but they all amount to one advice - "reopen the stdin after the file contents have been read".
View 1 Replies
View Related
Mar 28, 2011
when iam opening my dec_backup folder the folling error is appering :
the error is gzip :stdin:input /output error
/bin /gstar :unexpected EOF in archive
/bin /gstar: error is not recoverable :exesting now
View 1 Replies
View Related
Nov 20, 2009
i'm trying to redirect the output of a command to the input of the next command. not sure if i'm going about this the right way. an easy method would be just to store the output of the previous command in a file and redirect input to read that file, but i'm curious to see if this can be done without writing to any files.
View 9 Replies
View Related
Mar 9, 2011
I am trying to grep multiple numbers from file, grep does have the -f option for that.
Code: grep -f <`seq 500 520` /etc/passwd I know this could be done with
Code: for i in `seq 500 520`; do grep "$i" /etc/passwd; done But my question is fare more behind this example. It is possible to redirect one command output which will be treat as a content of file for another command ?
View 2 Replies
View Related
Aug 26, 2010
i have this error when i tried to compil a program :
[Code]...
View 9 Replies
View Related
Jun 20, 2009
Coming from Debian Sid and KDE, I am used to K3b and the problems during verify. Now with Fedora 11 and Brasero I'm also getting errors:
BraseroReadom stderr: Error trying to open /dev/sr0 exclusively (Device or resource busy)... giving up.
BraseroReadom stderr: WARNING: /dev/sr0 seems to be mounted!
BraseroReadom stderr: readom: Device or resource busy. Cannot open '/dev/sr0'. Cannot open SCSI driver.
[code].....
After going back and adding my user to cdrom and other groups, changing authorizations et.al., I am still getting errors that I don't have permissions to use the drive. I've read through forums and bug reports and find out that my problem isn't unique. Like with K3B, does the failure during verify usually leave me with a good burn anyway? Does anyone know of a gui burner that doesn't have the verify problem? Or, should I go back to burning on cli with wodim?
View 8 Replies
View Related
Apr 5, 2011
I want to output the stdout and stderr in a logfile,moreover i do want to log stderr also to a separate logfile, and print str to the screen I searched arround and tried:
Code:
$ command 2>&1 > log | tee -a log log.err
But then in log first the stdout appears, and then stderr.
View 1 Replies
View Related
May 19, 2010
Code:
MY_STDOUT=`my-command`
MY_STDERR=`my-command >&2`
That is, i want to have to run my-command only once and get the same result. I've tried this:
Code:
YYY=$(XXX=`{ echo -n 111; echo 222 >&2; }` 2>&1); echo $XXX $YYY
where "{ echo -n 111; echo 222 >&2; }" is my-command. But it gives this output:
Code:
222
111
instead of "111 222". What's wrong in my script?
View 2 Replies
View Related
Mar 7, 2011
i've tryed to get rid of the ugly plymouth splash screen and this outpout at boot now:
stdin: error 0
and so on... It also appears in my /var/log/boot.log and /var/log/casper.log. But the OS works, just like before. I would like to know how can i get rid of this error. Or how can i hide it? Can i redirect the output to dev null at boot time?
Here is boot.log
Code:
stdin: error 0
Generating locales...
sl_SI.UTF-8... up-to-date
Generation complete.
[Code]....
Because it is really annoying to see an "error" when your computer boots, even if it is not really an error
View 2 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