Hi,
Within my shell script (#!/bin/sh), when I have
$cmd > a.log 2>&1 &
this does kick off a job in the background.
On the command line, when I run
$cmd > > a.log 2>&1 &
Ambiguous output redirect.
Why is that?
Shell script : 2>&1 confusion
Page 1 of 13 Replies - 878 Views - Last Post: 28 May 2012 - 08:39 PM
Replies To: Shell script : 2>&1 confusion
#2
Re: Shell script : 2>&1 confusion
Posted 28 May 2012 - 08:23 PM
You have two redirects next to each other in your line of code.
You have cmd, output to, output to, a.log.
You have cmd, output to, output to, a.log.
#3
Re: Shell script : 2>&1 confusion
Posted 28 May 2012 - 08:35 PM
Not sure how this works fine through my shell script. Is it that the shell script is ignoring the second one?
So how do i get the stdout output to a.log, run it as a background process and stderr to say /dev/null?
cmd >& a.log < /dev/null &
So how do i get the stdout output to a.log, run it as a background process and stderr to say /dev/null?
cmd >& a.log < /dev/null &
#4
Re: Shell script : 2>&1 confusion
Posted 28 May 2012 - 08:39 PM
The "/dev/null 2>&1" tells the shell to send standard output & standard error to /dev/null, which is a file & basically means don't show output or errors. Now, you can't redirect standard output to both a.log & to /dev/null.
Can you further describe what you are trying to do?
Can you further describe what you are trying to do?
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|