Sponsored Content
Top Forums Shell Programming and Scripting I/O Redirection: how can I redirect error msgs to a temp file Post 302486224 by DGPickett on Friday 7th of January 2011 12:21:50 PM
Old 01-07-2011
Some messages are on stdout (1), some on stderr (2) (in bits!), none on /dev/tty, for my HPUX system:
Code:
$ truss -o /tmp/nsl.tr nslookup 12.23.34.45 ; grep write /tmp/nsl.tr          
Using /etc/hosts on:  hideme
looking up FILES
Trying DNS
Trying NIS
*** No hostname information is available for "12.23.34.45"
write(1, "U s i n g   / e t c / h o s t s ".., 32) ....... = 32
write(1, "l o o k i n g   u p   F I L E S ".., 17) ....... = 17
write(1, "T r y i n g   D N S \n", 11) ................... = 11
write(1, "T r y i n g   N I S \n", 11) ................... = 11
write(2, "* * *   N o   h ", 8) .......................... = 8
write(2, "o s t n a m e ", 7) ............................ = 7
write(2, "  i n f o r m a ", 8) .......................... = 8
write(2, "t ", 1) ........................................ = 1
write(2, "i o n   i s   a ", 8) .......................... = 8
write(2, "v ", 1) ........................................ = 1
write(2, "a i l a b l e   ", 8) .......................... = 8
write(2, "f ", 1) ........................................ = 1
write(2, "o r   " 1 2 . 2 ", 8) .......................... = 8
write(2, "3 . 3 4 . 4 5 ", 7) ............................ = 7
write(2, "" \n", 2) ...................................... = 2
$ 
 
 
 
Good IP:
 
$ truss -o /tmp/nsl.tr nslookup 89.67.45.123 ; grep write /tmp/nsl.tr
Using /etc/hosts on:  hideme
looking up FILES
Name:    hideme
Address:  89.67.45.123
Aliases:  hideme.somedomain.com
write(1, "U s i n g   / e t c / h o s t s ".., 32) ....... = 32
write(1, "l o o k i n g   u p   F I L E S ".., 17) ....... = 17
write(1, "N a m e :         h i d e m e \n".., 26) ....... = 26
write(1, "    8 9 . 6 7 . 4 5 . 1 2 3 ".., 26) ....... = 26
write(1, "    h i d e m e . s o m e d o ".., 34) ....... = 34
$
 
 
Good IP, PTR specific query for pointer-reverse = ip to name:
 
$ truss -o /tmp/nsl.tr nslookup -q=PTR 89.67.45.123 ; grep write /tmp/nsl.tr
Using /etc/hosts on:  hideme
looking up FILES
Trying DNS
123.45.67.89.in-addr.arpa    name = hideme.somedomain.com
write(1, "U s i n g   / e t c / h o s t s ".., 32) ....... = 32
write(1, "l o o k i n g   u p   F I L E S ".., 17) ....... = 17
write(1, "T r y i n g   D N S \n", 11) ................... = 11
write(1, "1 2 3 . 4 5 . 6 7 . 8 9 . i n - ".., 28) ....... = 28
write(1, "\tn a m e   =   h i d e m e . s ".., 34) ....... = 34
write(1, "\n", 1) ........................................ = 1
$
 
 
Good IP, specific DNS server:
 
$ truss -o /tmp/nsl.tr nslookup 89.67.45.123 89.123.45.67 ; grep write /tmp/nsl.tr 
Name Server:  nameserver1.somedomain.com
Address:  89.123.45.67
Trying DNS
Name:    hideme.somedomain.com
Address:  89.67.45.123 
write(1, "N a m e   S e r v e r :     n a ".., 50) ....... = 50
write(1, "    8 9 . 1 2 3 . 4 5 . 6 7 \n".., 17) ....... = 17
write(1, "T r y i n g   D N S \n", 11) ................... = 11
write(1, "N a m e :         h i d e m e ".., 44) ....... = 44
write(1, "    8 9 . 6 7 . 4 5 . 1 2 3 ".., 19) ....... = 19
$

Tools like this, called truss, tusc or strace, can tell you what you are seeing in more detail.

Last edited by DGPickett; 01-07-2011 at 01:44 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

redirect standard error into log file

Hi, I am new in shell scripting. Can anyone point out what wrong of below script. If I want the error output to "sqlerror.log" and database pool data output to "bulk_main.dat". Right now, the below script, if successful execute, the data will output to bulk_main.dat && sqlerror.log both... (7 Replies)
Discussion started by: epall
7 Replies

2. HP-UX

How to Redirect the error messages from Syslog file to our own Application Log File

Hello, I am New to Unix. I am Using HP-UX 9000 Series for my Application. I am Currently Facing an Issue that the error messages are being written in the syslog file instead of the Application Log File. The Codes for that Syslog.h is written in Pro*C. I want to know how to Redirect these... (3 Replies)
Discussion started by: balasubramaniam
3 Replies

3. Shell Programming and Scripting

Error file Redirection

Hello All, I was wondering is there any other way in Shell Scripting to redirect the errors to a output file inside a shell script with using a error status checking or a command line redirection. Say without doing this ksh test.ksh 2> error.txt or without doing this ... if ; then... (3 Replies)
Discussion started by: maxmave
3 Replies

4. UNIX and Linux Applications

mail: no space for temp file

I'm trying to read mail but I obtained this message: msgcnt 2446 vxfs: mesg 001: vx_nospace - /dev/vg00/lvol4 file system full (1 block extent) mail: no space for temp file I want to empty my mailbox How could I make this? Regards Leonardo Siza (3 Replies)
Discussion started by: usernamea
3 Replies

5. Solaris

troubleshooting log detailing symptoms/error msgs/fix actions for NIS+ client authent

summary found at bottom. to skip straight to action summary, ctrl+f for <summary> this initially started with trouble changing passwords due to client being unable to authenticate, this was further caused by missing client files. This was transparent to me, so this details the road I took,... (0 Replies)
Discussion started by: ProGrammar
0 Replies

6. Shell Programming and Scripting

How to avoid a temp file

Hi all. I want to check the free space on a given FS and process the output. Right now, I'm using a temp file to avoid using df twice. This is what I'm doing #!/usr/bin/ksh ... df -k $FS_NAME > $TMP_FILE 2>&1 if ]; then RESULT="CRITICAL - $(cat $TMP_FILE)" else cat $TMP_FILE | ...... (3 Replies)
Discussion started by: fox1212
3 Replies

7. Shell Programming and Scripting

Problem in redirecting ftp msgs to a log file

Hi all.. The following set of statements is used in a shell script to ftp a file to a remote machine I want to redirect the ftp messages thrown by the first ftp statement to a log file. As you can see there is a logic downstream to decide if the ftp was a success or not. But i am not... (5 Replies)
Discussion started by: hareeshkumaru
5 Replies

8. Shell Programming and Scripting

find and replace a string in a file without the use of temp file

Hi - I am looking for a replacing a string in a in multiple *.sql files in directory with a new string without using a temporary file Normally I can use sed command as below for W in ls `FILE*.sql` do sed 's/OLD/NEW/g' $W > TEMPFILE.dat mv TEMPFILE.dat $W done But Here in my... (9 Replies)
Discussion started by: raghutapal
9 Replies

9. Shell Programming and Scripting

Redirect grep error/result to file

I'm having trouble piping grep results/error to a file. Why can't I redirect these messages into a file? $ grep -r -o "pattern" * > log Binary file foo1 matches Binary file foo2 matches Binary file foo3 matches Binary file foo4 matches The log is created, but remains empty. ... (1 Reply)
Discussion started by: chipperuga
1 Replies
WRITE(1)						    BSD General Commands Manual 						  WRITE(1)

NAME
write -- send a message to another user SYNOPSIS
write user [tty] DESCRIPTION
The write utility allows you to communicate with other users, by copying lines from your terminal to theirs. When you run the write command, the user you are writing to gets a message of the form: Message from yourname@yourhost on yourtty at hh:mm ... Any further lines you enter will be copied to the specified user's terminal. If the other user wants to reply, they must run write as well. When you are done, type an end-of-file or interrupt character. The other user will see the message 'EOF' indicating that the conversation is over. You can prevent people (other than the super-user) from writing to you with the mesg(1) command. If the user you want to write to is logged in on more than one terminal, you can specify which terminal to write to by specifying the termi- nal name as the second operand to the write command. Alternatively, you can let write select one of the terminals - it will pick the one with the shortest idle time. This is so that if the user is logged in at work and also dialed up from home, the message will go to the right place. The traditional protocol for writing to someone is that the string '-o', either at the end of a line or on a line by itself, means that it is the other person's turn to talk. The string 'oo' means that the person believes the conversation to be over. SEE ALSO
mesg(1), talk(1), wall(1), who(1) HISTORY
A write command appeared in Version 1 AT&T UNIX. BUGS
The sender's LC_CTYPE setting is used to determine which characters are safe to write to a terminal, not the receiver's (which write has no way of knowing). The write utility does not recognize multibyte characters. BSD
July 17, 2004 BSD
All times are GMT -4. The time now is 02:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy