1

i have a problem between nc and tee, tee should take the output of nc and print it inside a TXT FILE as you all know. in kali its working fine, but in Ubuntu the file is created but empty. (nothing is written in it)
i'm using python to call this to command.

cmdping = "sleep 5; echo load_audio "+ids[i][0]+"| nc 127.0.0.1 1234 | tee >> "+logtxt
p=subprocess.Popen(cmdping, shell=True, stderr=subprocess.PIPE)


i think its a permission issue, or not i don't know, help is appreciated, thank you.

Z. Kiwan
  • 123
  • 1
  • 14
  • What's the name and location of the file 'logtxt'? How does that compare to the user you're running the program under? I'd also say that `tee` takes a filename as an argument, and that `| tee >> filename` isn't really useful, as it's just doing the same as `>> filename`. `| tee filename` will write to the file and to stdout – Simon Fraser Jul 13 '15 at 12:19
  • i'm using `>>` to append the txt file, logtxt is the combination of the path that is chosen by the user and log.txt example `logtxt=path+"/log.txt"` usually the path is somewhere around the desktop. – Z. Kiwan Jul 13 '15 at 12:22
  • If you print out the value of `logtxt` being used, can you write to that file outside the program? – Simon Fraser Jul 13 '15 at 12:23
  • Yeah i can, write to it outside the program actually the file is being created, so its not the problem so far. – Z. Kiwan Jul 13 '15 at 12:25
  • When you run the echo and nc, does it still produce output? If so, it might be worth taking the whole `| tee` off the end and then reading from stdout and stderr to see if Python can get the text. I would try the simpler version, without tee, replacing `| tee >> " + logtxt` with `>> " + logtxt`, to see if it's an error there, too. – Simon Fraser Jul 13 '15 at 12:28
  • actually no there is no output on the terminal when i remove the tee... it's shocking everything is working fine on kali, but not on ubuntu... – Z. Kiwan Jul 13 '15 at 12:29
  • Different versions of netcat, perhaps? Different behaviour there. – Simon Fraser Jul 13 '15 at 12:30
  • oh could be let me take a look please – Z. Kiwan Jul 13 '15 at 12:32
  • on Ubuntu its debian patch level 1.105-7ubuntu1 on kali its 1.10-40 if this is the problem do you have any idea how to solve it ? – Z. Kiwan Jul 13 '15 at 12:40
  • Off the top of my head, no - perhaps there is a different default so that one version prints out what it receives and the other doesn't? – Simon Fraser Jul 13 '15 at 12:54
  • found a solution i will post it :) thank you tho! – Z. Kiwan Jul 13 '15 at 13:10

1 Answers1

1

After research, i found out that Kali uses traditional Netcat but Ubuntu uses open BSD netcat, which each one of them acts differently, all you have to do is to install traditional netcat and everything will be fine. steps to install netcat are in the link below:

How to switch to netcat-traditional in Ubuntu?

Community
  • 1
  • 1
Z. Kiwan
  • 123
  • 1
  • 14