LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-03-2008, 09:57 PM   #1
john.daker
Member
 
Registered: Jul 2008
Posts: 33

Rep: Reputation: 15
How to redirect standard stdout to multi stdout ( Bash )?


Hi,all
How to redirect standard stdout to multi stdout ( Bash )?

For example:

Code:
bash:~$ ls
bash:~$ bash
$ exec 11>a
$ exec 12>b
$ exec 1>&11
$ exec 1>&12
$ ls
$ exit
exit
bash:~$ ls -l
-rw-r--r-- 1 jh users 0 2008-11-04 11:55 a
-rw-r--r-- 1 jh users 4 2008-11-04 11:55 b
What I want is the output of `ls` is sendto both a and b

How to do this?

Thanks
 
Old 11-03-2008, 10:36 PM   #2
gjagadish
Member
 
Registered: Oct 2005
Location: India
Distribution: Fedora Core
Posts: 88

Rep: Reputation: 15
$ ls -lh | tee file1 > file2

Now both file1 and file2 files will have the output of ls -lh command
 
Old 11-03-2008, 11:02 PM   #3
john.daker
Member
 
Registered: Jul 2008
Posts: 33

Original Poster
Rep: Reputation: 15
But what if I want to send the output not to files,like cmd's stdin?
 
Old 11-03-2008, 11:04 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,670

Rep: Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487
Can you explain why you want to do this, I've got a feeling you may be asking the 'wrong' qn ie this isn't the soln you want. If you see what I mean..
 
Old 11-03-2008, 11:20 PM   #5
john.daker
Member
 
Registered: Jul 2008
Posts: 33

Original Poster
Rep: Reputation: 15
Simply, what I want is to send the input to several processes;

Take Konsole for example:

Open two sessions in Konsole , one fork the cmd `bc -q` and the other forks the cmd `gdb` , and enable the "Send the input to all sessions" in Konsole.

So when i type `asdf` in session 1 , session 2 got this `asdf` too.

I want my bash script to have this function, send my input to several processes as their input.

How ?

Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
redirect AND print stdout samel_tvom Programming 12 10-07-2012 05:37 PM
Redirect stdout to xterm window rwengr Programming 2 06-23-2006 01:01 PM
redirecting stdout to /dev/null and stderr to stdout? Thinking Programming 1 05-18-2006 02:36 AM
redirect stdout of os.system()? Chowroc Programming 7 03-02-2006 10:56 PM
redirect stdout to a varible Furlinastis Programming 3 12-07-2005 06:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration