Ubuntu :: Netcat Output Pipes And Redirection ?
May 25, 2010I'm trying to redirect nc command output but I can't do it.
I have tried this:
And this:
But it seems doesn't work.
I'm trying to redirect nc command output but I can't do it.
I have tried this:
And this:
But it seems doesn't work.
see these simple commands:
Code:
# dbus-monitor --system >> /data/eject.txt
This one works as expected ... dbus-monitor never terminates and whenever it outputs new lines, they are
[code]....
i am running ncat (netcat's new version from nmap) on centos . I am listening on different ports. My question is , is it possible that when a connection is received on a port say 123, i redirect this connection to a different port and use the 123 port again for listening connections. ncat has an option -k which u can add with -l , it will force fully listen on the port. It can accept multiple connections on a single port but i want that once a client connects on to 123 port, he is forwarded to some other port and no longer on 123.
View 4 Replies View RelatedI need to find one RUNNING word in latest created logs.
and as soon as i will get RUNNING WORD , i have to execute another Unix Command.
I wrote following script code...
Is there already a program that reads multiple pipes or file descriptors and writes to the standard output (not splitting lines).Like cat, but reading all files simultaneously and preserving lines.It is needed to avoid coding of select/epoll loops or using multithreading in simple programs. Like "select loop for bash".
View 1 Replies View RelatedI have a program that writes to stdout. Is there a way that I can redirect the output to the linux diff command or do I have to write the output to a file and then compare that. For example I have a bunch of test input files for a program and the corresponding expected output in another set of files. And I'd like to do something like ./program < t1.input | diff t1.expected.
View 3 Replies View RelatedI'm working on some scheduled task script files to keep nightly backups of some of our database information in place, and it's a bit annoying when they blow up. I know how to redirect stdout and stderr to a flat file I can view when I come in, and I know that 2>&1 maps them both to the same file (whatever was named in 1). However, I'm running into some cron-time situations where it's easier to have the two streams together, and other cron-time situations where it's easier to have them separated. I can't really tell which is going to happen; is there some way I could create both kinds of output file for my scripts, so that I've got a std_err only file and an interleaved std_out/std_err file?
Note: I've looked at the 'tee' command, but I don't think it will work for what I'm after. 'tee' appears to only work with stdout; I'm trying to work with stderr.
I have an X11 GTK program, let's name it "foo".I would like to start it from command line, either from a text console, or from an ssh log-in. I want to run foo with Administrator privileges and in higher priority, and I need redirect standard output and standard error. Standard errors must go to syslog, except "libglade Warning" messages and empty line messages. Standard output is redirected to a file.I wrote a script, called "foo-start". The "foo" program must run continously, so the "foo-start" script should not wait for "foo"'s termination.The scrip actually looks likelike this:
cd "FOO'S DIR"
(sudo nice --10 ./foo --display=localhost:0 &) 3>&1 1>foo-output.log 2>&3 | grep . | grep -v lobglade-WARNING | loggerr -p local7.err -t foo &
[code]....
I've been using pipes and redirects for a long time and just realized that I don't know exactly how they are different. I just know that if you want to store the output in a file, then you use >. Otherwise most of the time you just use |. difference between pipes and redirects?
View 1 Replies View RelatedAlthough this is a basic stuff, but still i wonder.
Consider these two examples. code...
I wonder, why doesn't redirection work in first case? when to use redirect and when to use pipes? I have been Linux for a long time, but still this basic stuff baffles me.
File descriptors with pipes-Can someone help me with this three situations, what would happen?
a) a process open the same file twice and read through two file descriptors
b) a process does fork and both parent- and child-processes read parallell
c) two processes opens and read from same file.
has anyone seen this before, when running an ssh command as normal user via ssh i get results:
ssh picolo 'ls -d /var/sadm/pkg/* | egrep "Prod|Dev|UAT" |cut -d/ -f5;uname -r;grep -v "^#" /opt/Tivoli/lcf/dat/1/DMXAdaptiveFileSystem.dat'>>sshnotroot
and it creates file
more sshnotroot
Prod
5.10
[Code]...
I have two sources of internet which I want to share and balance the load on. With one source it's easy: plug it into the wireless router and Bob's your uncle. But how would you handle two sources and get load balancing? A switch? Would that really share the load?
View 4 Replies View RelatedHow to create and use named pipe on linux network.ie
client - my linux machine
server - my fren's linux machine
how to communicate between these two using named pipe created in C? do u have any similar code snippet written in C??
i got one server client application,its working fine on my machine.So i want enhance that code for networking.so help in this...
recently I had been to interview where I had a question to be answered, that what are advantages and disadvantages when desiging an application in linux.
View 1 Replies View RelatedI have three machines networked to my desktop which run a bunch of simulations in parallel. As they're running, I connect to them via SSH and screen to keep an eye on the runs and look at the output. They stay usually connected for days at a time. The SSH servers and client are running Fedora 14. Yesterday one of my coworkers accidentally yanked the plug on one of the servers while it was running. When I powered it up again, I started getting some odd connection problems. I couldn't connect to it via SSH initially because I got the Remote Host Identification Changed (RSA host key changed) error. I deleted the key in .ssh/known_hosts, which allowed me to connect, but it denied my password. I then logged into that machine locally, restarted sshd, and removed .ssh/known_hosts again. Now I can log in via SSH without problems. However, the connection dies with a "Write failed: Broken pipe" error every few minutes (as opposed to the other two machines, which stay connected indefinitely).
So my questions are:
1.) why would a power loss affect the behavior of the SSH server?
2.) why do I keep getting broken pipes now?
i'm trying to clone a hard drive using dd & netcat.
Quote:
on target:
nc -l -p 1333 |dd of=/dev/sdb
on source:
dd if=/dev/sdb |nc 192.168.0.5 1333
However after a while since the process was initiated I get a
I/O error in filesystem ("....") meta-data dev ...block 0x..... ("xfs_read_buf") error 5 buf count 512 XFS: size check 2 failed
Further digging showed that the target hard drive was less in space by 100 kb. Both are 1 T drives seagte but different models, hence the diff in space maybe.The data on the original drive is only 900 GB.
I've tried to use netcat in the past and assumed it was my stupidity that was preventing it from working... but this is getting ridiculous. I'll execute nc -l 3333 on a server at 192.168.0.105 (after opening it on the firewall of course) then I run nc 192.168.0.105 3333 on my laptop (from 192.168.0.101). and nothing happens... i start typing and nothing comes up on the terminal.
I run nc -z 192.168.0.105 80 which should ideally do a port scan of port 80 on that server (of which I'm running a web server that clearly works) but it doesnt even give me any feedback. Nothing happens. Now when I use the verbose flag i see that I am indeed connecting to the specified port on the server successfully (so the port scan one is a success but only with the verbose flag... which shouldnt be the case I believe). But still once I have the server listening and the laptop connected... I type in both windows and nothing happens...
OK here's what I'm doing:
On terminal 1, I enter:
$ nc6 -vlp 5000
nc6: listening on 0.0.0.0 5000 ...
On terminal 2, I enter:
$ nc6 -v localhost 5000
nc6: ygt-asfandq (127.0.0.1) 5000 [5000] open
Now, as SOON as I make the connection on terminal 2, both netcats immediately quit back to the command prompt. The return code for both is 0.
I do not have ANYTHING in my firewall (I checked with sudo iptables -v -L)
I have attached a wireshark trace of the conversation..
So I opened a terminal and fired up netcat.I only wanted to view the Foreign Ip Addresses so I used
Code:
netstat --tcp --numeric | cut -c 45-65
and that gave me[code]...
There are two things that I am trying to accomplish here. The first is that I would like to "cut" the first three horizontal lines so that the output is only ip addresses.I tried tail but the number of different IPs changes so it still gives me those top lines. I tried head but that doesn't seem to give me any output at all.The second thing I would like to do is to filter out duplicate values. For example the output above has 2 duplicate entries of 66.102.7.101:80
I'm using something like this to send file from one computer to another:To serve file (on computer A):
cat something.zip | nc -l -p 1234 To receive file (on computer B): netcat server.ip.here. 1234 > something.zip can I do the opposite? Let's say I have file on computer B and I want to send it to A but not the way I wrote above, but by making computer that's supposed to receive file (A) be 'listening' server and connect computer that's 'sending' file (B) to server and send the file? Is it possible? I think it might be but I'm not sure how to do this.
In case my above explanation is messed up: How do I send file TO 'server' instead of serving the file on server and then taking it FROM it (like I did above)?
I am new in linux. I am using opensuse 11.4. How can I ping a DNS using netcat?
View 6 Replies View RelatedHow can i send udp packet to the DNS using netcat in opensuse.
View 7 Replies View RelatedI'm wondering if I can use netcat to listen to a UDP port and display ALL incoming packets, no matter where they're from. If I just do 'nc -u -l 1234' then netcat will listen for incoming packets and connect() to the source address of the first one it sees (I can see this with strace). Is there any (standard) way to stop the connect() call? I can make a hack to block connect() with a function of my own, but that'd be ugly
View 6 Replies View Relatedi have to control vlc which is running on my pc through console application.I heared like it can be controlled using netcat and rc interface but not getting the procedures how exactly its can be implemented.So if anyone knows pls explain me with steps.i want to do this in windows and i'm using vlc version 0.8.6.
View 1 Replies View RelatedI connected two machines, I have their given of the addresses ip in a static way and not with DHCP. I gave to the machine server the address: 192.168.0.1, and in the machine client the address 192.168.0.2.
View 5 Replies View RelatedHere is my problems :I have two networks :1. LAN (10.1.x.x subnet 255.255.0.0), and2. my internet public (IP 202.xx.xxx.xxxx subnet 255.255.255.240)I have an application in my LAN PC (10.1.2.240) which broadcast udp packet to its client. The client in my LAN can receive the udp packet, no problem.My question is how netcat/socat can RELAY the udp broadcast packet to one of my IP public address so the message can be received by other client from internet ?
View 5 Replies View Relatedi have 3 servers in 2 dcs as follows; server 1 (dc1 - dmz) --- server 2 (dc1 - internal) --- server 3 (dc2 - internal) Now I have an application in server1 that have to connect to port 44000 in server 3 but dc refuse to open connection saying they do not open connections between dmz and dc2 (i have no say over this).
However I can connect to virtually any port from server1 <-> server2 and also server2 <-> server3. Is it possible to do something like;
server1 <-> server2 <-> server3:44000 using nc to get the app work.
I made a simple proxy using netcat and it works great, the idea is to make the server and client communicate through two named pipes, file1, file2.
$ mknod file1 p
$ mknod file2 p
$ nc -l -p 12345 0<file1 1>file2 &
$ nc 192.168.2.118 80 1>file1 0<file2 &
The problem Im facing is that I cant seem to intercept the data going between the client and the server. I want to be able to have the data coming to the server in a variable, manipulate it and send it to the client, and the other way, have the data coming to the client in a variable, manipulate it and send it to the server.
Im running on an embedded device where tee, awk and many other commands are absent. how can I redirect the data to a variable, manipulate it and pass it to the other side, that is the question.
I've always been curious about this but say that you had computer A which runs headless and had music that you wanted to hear from computer B. Sure you can setup vlc or icecast on computer A and stream it. But what if you could forward the sound over netcat. For example, say when you play a sound file on Computer A data gets sent to /dev/snd.Would be possible to do something like the following.
Computer B
nc -lvp 6666 > /dev/snd
Computer A
cat /dev/snd | nc -v -w 5 computer_b 6666
And be able to hear sound playing on Computer A? point me in the right direction to find out about how to do this?