0

This ruby 'system' gives me an output; on irb:

system("sudo airodump-ng -w sidney wlan0")

Airodump-ng is from the Airocrack-ng package.

However, the ruby "system" should not give me a stdout. The thing is, that a "sh" processus is being created, which doesn't have an output. But the "sh" processus got a child processus, which gives me a output that I don't want at all to be displayed on my terminal.

Second part of the question, how can I get the pid of that sub-processus, using threads and maybe a different way to call a shell command using ruby (and not displaying the output of that child processus) ?

sidney
  • 2,704
  • 3
  • 28
  • 44
  • I'm not sure this is exactly what you need, but have tried creating a wrapper to get the process and running within this? We've had this problem previously and solved this way. Theres a load of examples on SO http://tldp.org/LDP/abs/html/wrapper.html – simonmorley Nov 29 '12 at 09:00
  • You don't want *any* output at all? – Mark Thomas Nov 29 '12 at 13:31
  • related: http://stackoverflow.com/questions/1960838/suppressing-the-output-of-a-command-run-using-system-method-while-running-it-i – Ciro Santilli OurBigBook.com Nov 03 '14 at 21:16
  • nope, that question and mine are different, and the answers are differents as well. – sidney Nov 04 '14 at 10:38

2 Answers2

2

If you don't care about the output, trash it:

system("sudo airodump-ng -w sidney wlan0 >/dev/null 2>&1")

I think the child process will inherit the parent's file descriptors.

glenn jackman
  • 238,783
  • 38
  • 220
  • 352
1

Use

out = `sudo airodump-ng -w sidney wlan0`

instead, and output will not show on screen, but stored in out instead

Haocheng
  • 1,323
  • 1
  • 9
  • 14
  • It doesn't work, the output of the second child is shown. Please try it on irb, you will see that it is displayed :-( And here, I would like to retrieve the second child's pid. I can't :/ – sidney Nov 29 '12 at 12:50
  • 1
    @sidney That may mean that airodump-ng is sending stuff to STDERR. Try adding `2>&1` to the above command. – Mark Thomas Nov 29 '12 at 13:29