Broadcast your shell thru ports 5000, 5001, 5002 ...

script -qf | tee >(nc -kl 5000) >(nc -kl 5001) >(nc -kl 5002)
run 'nc yourip 5000', 'nc yourip 5001' or 'nc yourip 5002' elsewhere will produce an exact same mirror of your shell. This is handy when you want to show someone else some amazing stuff in your shell without giving them control over it.

40
By: clvv
2010-10-11 07:55:30

3 Alternatives + Submit Alt

What Others Think

nc: invalid option -- q
DaveQB · 571 weeks and 6 days ago
nc-1.84-10.fc6.x86_64 CentOS 5
DaveQB · 571 weeks and 6 days ago
Looks like CentOS' nc doesn't support -q option, simply remove the -q0 argument, it will still work, but nc will still be running in background even if your terminated your broadcast session.
clvv · 571 weeks and 6 days ago
mkfifo /tmp/fifo;(nc -q0 -l 5000 < /tmp/fifo > /dev/null &);script -f /tmp/fifo Is a little better, because nc -l will echo text received by client. So in my modified script STOUT is redirecting to /dev/null. no more echo will be shown
anonjoe · 571 weeks and 5 days ago
mkfifo /tmp/fifo;(nc -q0 -k -l 5000 < /tmp/fifo > /dev/null &);script -f /tmp/fifo add -k to nc, so your command will stay online even when your client will disconnect
anonjoe · 571 weeks and 5 days ago
A simpler way: script -f >(nc -l 5000)
dstahlke · 571 weeks and 4 days ago
why do you all forget the -p before the 5000 ??? I took me so long to figure that out, couldn't make it work before until I put the -p: mkfifo /tmp/fifo;(nc -q0 -l -p 5000 < /tmp/fifo &);script -f /tmp/fifo mkfifo /tmp/fifo;(nc -q0 -k -l -p 5000 < /tmp/fifo > /dev/null &);script -f /tmp/fifo script -f >(nc -l -p 5000) Great tip by the way, now I can vote for it and make it as favorite.
nickwe · 570 weeks and 3 days ago
doesn't work for me unless I change this: nc -l 5000 ...to this: nc -l -p 5000 (tested on ubuntu 10 LTS and debian 5
linuxrawkstar · 570 weeks and 3 days ago
doesn't work for me unless I change this: nc -l 5000 ...to this: nc -l -p 5000 (tested on ubuntu 10 LTS and debian 5
linuxrawkstar · 570 weeks and 3 days ago
Is there an extra option which will allow multiple clients listening to your broadcast?
alperyilmaz · 547 weeks and 1 day ago
I think the solution is "socat" but couldn't figure out the options..
alperyilmaz · 547 weeks and 1 day ago
@alperyilmaz I haven't figure out a way to do this only using common utilities yet. But here is a quick work around: script -qf | tee >(nc -kl 5000) >(nc -kl 5001) >(nc -kl 5002)
clvv · 547 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: