- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Redirecting a result ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 08:47 AM
03-20-2006 08:47 AM
how can i redirect an output ..
for example,
i have script run a script , this script uses a command named fdx .. this will output a result
i want this result to keep in a file ..
script send_information.sh contains:
/home/usr1/send.sh >> /tmp/log.txt
and file send.sh contains:
fdx -u inf_bank.txt $URL
but when i run send_information.sh , the output is not kept in the file indicated: log.txt
why ..
do i must put 2 before >> this do not work !!!
Thanks Manuales.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 08:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 08:56 AM
03-20-2006 08:56 AM
Re: Redirecting a result ...
/home/usr1/send.sh >> /tmp/log.txt 2>>&1
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:06 AM
03-20-2006 09:06 AM
Re: Redirecting a result ...
it does not work !!!!!!!
when i run it with sh -x ...
in the output appears:
+ /home/usr1/send.sh
+ 1>>/tmp/log.txt
.....
.....
.....
and the output i can not keep it into file log.txt !!!!
how do i must use & ?
Thanks, Manuales.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:10 AM
03-20-2006 09:10 AM
Re: Redirecting a result ...
friend ..
with /home/usr1/send.sh >> /tmp/log.txt 2>>&1
what means 2>>&1 ?
i do not understand &1 ..
thanks, Manuales.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:11 AM
03-20-2006 09:11 AM
Re: Redirecting a result ...
Looks like the script is erring out and hence you see stderr on your teminal and not in the file. Redirect stderr also to the file and post the output here:
/home/usr1/send.sh >> /tmp/log.txt 2>>&1
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:15 AM
03-20-2006 09:15 AM
Re: Redirecting a result ...
&1 means re-directing stderr to the same place as stdout. The file descriptor 1 stands for standard output and 2 stands for standard error and the notation 2>>&1 means re-direct stderr (2) to the same place as stdout (1) which in your case is "/tmp/log.txt"
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:17 AM
03-20-2006 09:17 AM
Re: Redirecting a result ...
this was resulted:
"Ambiguous output redirect."
help me !!!
it is not posible an easy thing be dificult for me !!! :'(
HELP ....
SOS ....
Thanks ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:17 AM
03-20-2006 09:17 AM
Re: Redirecting a result ...
I believe, too, that Jeff is correct. That is, your "send.sh" is probably writting the information you want to STDERR and not STDOUT.
STDERR is file descriptor-2 whereas STDOUT is file descriptor-1.
The shell opens these descriptors for you.
In a shell, a simple 'echo' or 'print' writes to STDOUT. A 'print -u2' statement writes to STDERR.
If you want to capture *both* STDOUT and STDERR into the same file, you do:
... 1>>file 2>&1
...which means take the output of STDOUT (1) and redirect it to 'file'. At the same time, assign STDERR (2) to file descriptor #1 (which is now 'file'). Thus, *both* streams are redirected to your 'file'.
The ">>" notation means "append", whereas a single ">" means create or truncate to zero-length and then begin writting.
See the man pages for 'sh-posix'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:18 AM
03-20-2006 09:18 AM
Re: Redirecting a result ...
I hope this clears up the 2>&1 for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:32 AM
03-20-2006 09:32 AM
Re: Redirecting a result ...
does not work ...
o.k., i have to be patient ..
script send_information.sh contains:
/home/usr1/send.sh >> /tmp/log.txt
and file send.sh contains:
fdx -u inf_bank.txt URL
If i run as follows
send.sh
the output a can see it on line ...
why??
SOS !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:35 AM
03-20-2006 09:35 AM
Re: Redirecting a result ...
Try this at your command line:
# /home/user1/send.sh 2> /dev/null
Do you still see all of the output you did before?
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:40 AM
03-20-2006 09:40 AM
Re: Redirecting a result ...
Another mentions not being able to nest redirections like "(eval '(echo matter >fullness)') >void". Maybe you're redirecting stdout of send_information.sh also? That would cause problems.
BTW, I added an extra < in my previous post. The proper syntax to redirect stderr to stdout, appending to file, is:
script >> file 2>&1
Jeff Traigle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:45 AM
03-20-2006 09:45 AM
Re: Redirecting a result ...
I continuew seeing the output ..
with follows:
send.sh 1>/dev/null
send.sh 2>/dev/null
send.sh >/dev/null
i see result on line ...
fdx is a command like ftp ...
fdx indicates "Trying 111.222.333.444
Connected...."
this output i require keeping ...
Help me!!
Manuales.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:50 AM
03-20-2006 09:50 AM
Re: Redirecting a result ...
at the beggining of the script i'm using
#!/usr/bin/csh
env command:
SHELL=/usr/bin/csh
and script has at the end: ".sh"
do i must put ".csh"?
Manuales.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 09:56 AM
03-20-2006 09:56 AM
Re: Redirecting a result ...
Yikes! Using the 'csh' shell leads to brain-damage! Please read this:
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 12:14 PM
03-20-2006 12:14 PM
Re: Redirecting a result ...
You are using the 'csh' (C-shell) because your interpreter line (The "sheebang" that begins with #!) is "#!/usr/bin/csh".
That, and that alone governs the shell that will be run.
What you name the script is immaterial. You can call the script "script.sh" or merely "script". This is not evaluated when a determination of what to run is made by the kernel. What is, is the interpreter name following the sheebang.
Even though your user uses a 'csh' *your* script can still be written as a Poxix shell and call any other script or binary to execute. Then, the methods for redirecting output shown above can easily be made to work in *your* script.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2006 11:17 PM
03-20-2006 11:17 PM
Re: Redirecting a result ...
if you live in a (t)csh environment:
/home/usr1/send.sh >>& /tmp/log.txt
will redirect the stdout AND errout to the logfile.
mfG Peter