LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-17-2013, 06:02 PM   #1
djg2002
LQ Newbie
 
Registered: Jun 2013
Posts: 1

Rep: Reputation: Disabled
Command output redirection > doesn't print to file


I've used Linux for a while but am stumped. I just installed stun and ran the following:

david@smurf > stunc stun.stunprotocol.org -b > res
assign_socket: local socket is bound to 0.0.0.0:48157
stunc_bind_cb: stun_discovery_done
stunc_bind_cb: local address NATed as 13.135.7.82:48157
david@smurf > more res
david@smurf >

i.e. nothing got written to 'res' but continued to be output to screen.

What do I need to do to get access to the output? (I need it for a script I'm putting together).

Thanks,

David

(Ubuntu 12.04)
 
Old 06-17-2013, 07:48 PM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
why are you trying to redirect before the command as well as after?

Code:
[user@server ~]$ nmap -p22 google.com

Starting Nmap 5.51 ( http://nmap.org ) at 2013-06-17 16:36 EDT
Nmap scan report for google.com (74.125.140.101)
Host is up (0.036s latency).
Other addresses for google.com (not scanned): 74.125.140.102 74.125.140.113 74.125.140.139 74.125.140.100 74.125.140.138
rDNS record for 74.125.140.101: ye-in-f101.1e100.net
PORT   STATE    SERVICE
22/tcp filtered ssh

Nmap done: 1 IP address (1 host up) scanned in 0.56 seconds
[user@server ~]$ nmap -p22 google.com > foo.txt
[user@server ~]$ cat foo.txt 

Starting Nmap 5.51 ( http://nmap.org ) at 2013-06-17 16:36 EDT
Nmap scan report for google.com (74.125.140.138)
Host is up (0.024s latency).
Other addresses for google.com (not scanned): 74.125.140.100 74.125.140.139 74.125.140.113 74.125.140.102 74.125.140.101
rDNS record for 74.125.140.138: ye-in-f138.1e100.net
PORT   STATE    SERVICE
22/tcp filtered ssh

Nmap done: 1 IP address (1 host up) scanned in 0.36 seconds
like that. your output indicates that you are trying to redirect the input into the output, that is not going to work.

also please use code flags. [ code ] [ / code ] remove the spaces and put your copy/paste from the CLI into them.

p.s. if you are putting this into a script, it might be a good idea to use >> instead of >

> will create the file and overwrite 100% of data inside the file.
>> will create the file if it does not exist and if it does it will "append" to the end of the file the new output.

Last edited by lleb; 06-17-2013 at 07:49 PM.
 
Old 06-17-2013, 07:59 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Try
Code:
stunc stun.stunprotocol.org -b > res 2>&1
 
1 members found this post helpful.
Old 06-17-2013, 08:46 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
As hinted by UnSpawn, stdout (chan 1) is going to the file, but stderr (chan 2) is not, so you need to change that.

@lleb: I don't think that's a re-direct before the cmd, more like the last part of his bash prompt.
 
1 members found this post helpful.
Old 06-18-2013, 11:43 PM   #5
pawandarkknight
LQ Newbie
 
Registered: Jun 2013
Location: india
Posts: 1

Rep: Reputation: Disabled
Thanks Sir !!
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell command output redirection - sudo doesn't block, can't supply passwords johndir Linux - General 6 11-22-2011 09:45 AM
[SOLVED] Output redirection doesn't work with iptables (Fedora Core 11) andrei.wap Linux - Newbie 8 03-17-2011 05:30 PM
Output Redirection - Trying to output to screen and file? helptonewbie Linux - Newbie 7 03-19-2009 07:05 AM
command output redirection radiodee1 Linux - Newbie 1 01-02-2008 11:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:00 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
Open Source Consulting | Domain Registration