* bash scripts creating log files
@ 2002-09-17 11:15 Paul Furness
2002-09-17 12:45 ` Exporting display Abhijit Vijay
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Paul Furness @ 2002-09-17 11:15 UTC (permalink / raw)
To: linux-newbie
Hi, everyone.
I'm trying to write a bash script which is basically a wrapper around a
number of other commands.
What I _want_ to do is basically _copy_ stdout and stderr to a log file.
Thus, when I run a command, I wans the stdout and stderr to go to
wherever called the script (eg an interactive terminal) but I _also_
want it to go to a log file.
I can do it easily for things I'm echoing in my own script by writing a
function like this:
function ECHO
{
echo $1
echo $1 >> ${Logfile}
}
and then any messages which I generate I use ECHO instead of echo:
ECHO "This is a message"
What I can't figure out is how do I redirect the output of the things
I'm running to the same 2 places?
Anyone know a nice easy way to do this?
Tnx.
Paul.
--
Paul Furness
Systems Manager
2+2=5 for extremely large values of 2.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Exporting display
2002-09-17 11:15 bash scripts creating log files Paul Furness
@ 2002-09-17 12:45 ` Abhijit Vijay
2002-09-21 19:08 ` Kenneth Stephen
2002-09-17 13:04 ` bash scripts creating log files Jos Lemmerling
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Abhijit Vijay @ 2002-09-17 12:45 UTC (permalink / raw)
To: linux-newbie
Hi Everyone,
I connect to a Linux machine using SSH from a Windows
NT workstation and need to bring up graphical programs
on my console. I find that I am unable to do this...
Could anyone please tell me what I should do?
Here's what I did...
1. Run XWin on my workstation. This shows up on my
system tray
2. Execute "setenv DISPLAY ${REMOTEHOST}:0.0" after
connecting to my linux machine through SSH
3. echo $REMOTEHOST gives me hughes08.biac.duke.edu
(my Windows NT workstation)
4. echo $DISPLAY gives me hughes08.biac.duke.edu:0.0
However, when I type xbiff& after connecting to my
linux machine, I just get the process ID. The xbiff
window does not show up!
Regards,
Abhijit.
__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bash scripts creating log files
2002-09-17 11:15 bash scripts creating log files Paul Furness
2002-09-17 12:45 ` Exporting display Abhijit Vijay
@ 2002-09-17 13:04 ` Jos Lemmerling
2002-09-17 13:13 ` Carl
2002-09-17 16:01 ` Paul Furness
3 siblings, 0 replies; 6+ messages in thread
From: Jos Lemmerling @ 2002-09-17 13:04 UTC (permalink / raw)
To: linux-newbie
On 17 Sep 2002, Paul Furness wrote:
> What I _want_ to do is basically _copy_ stdout and stderr to a log file.
>
> Thus, when I run a command, I wans the stdout and stderr to go to
> wherever called the script (eg an interactive terminal) but I _also_
> want it to go to a log file.
>
> I can do it easily for things I'm echoing in my own script by writing a
> function like this:
>
>
> function ECHO
> {
> echo $1
> echo $1 >> ${Logfile}
> }
>
> and then any messages which I generate I use ECHO instead of echo:
>
> ECHO "This is a message"
>
> What I can't figure out is how do I redirect the output of the things
> I'm running to the same 2 places?
"tee" is your friend:
echo test | tee -a logfile.txt
test is printed to the screen and appended to the file "logfile.txt". If
you don't use the "-a" the file is overwritten every time.
HTH
--
Jos Lemmerling on Debian GNU/Linux jos(@)lemmerling(.net)
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bash scripts creating log files
2002-09-17 11:15 bash scripts creating log files Paul Furness
2002-09-17 12:45 ` Exporting display Abhijit Vijay
2002-09-17 13:04 ` bash scripts creating log files Jos Lemmerling
@ 2002-09-17 13:13 ` Carl
2002-09-17 16:01 ` Paul Furness
3 siblings, 0 replies; 6+ messages in thread
From: Carl @ 2002-09-17 13:13 UTC (permalink / raw)
To: linux-newbie
At 12:15 17/09/2002 +0100, Paul Furness wrote:
>Hi, everyone.
>
>I'm trying to write a bash script which is basically a wrapper around a
>number of other commands.
>
>What I _want_ to do is basically _copy_ stdout and stderr to a log file.
>
>Thus, when I run a command, I wans the stdout and stderr to go to
>wherever called the script (eg an interactive terminal) but I _also_
>want it to go to a log file.
>
>I can do it easily for things I'm echoing in my own script by writing a
>function like this:
>
>
> function ECHO
> {
> echo $1
> echo $1 >> ${Logfile}
> }
>
>and then any messages which I generate I use ECHO instead of echo:
>
> ECHO "This is a message"
>
>What I can't figure out is how do I redirect the output of the things
>I'm running to the same 2 places?
There is a command called "tee" which will pipe data to a file and stdout/stderr at the same time
you do:
someprog | tee /tmp/some.log.file
The output of someprog is sent to stdout/stderr and the file /tmp/some.log.file
You can then do what you like with stdout/stderr as normal.
tee should be installed as it comes with sh-utils package.
--
Carl
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bash scripts creating log files
2002-09-17 11:15 bash scripts creating log files Paul Furness
` (2 preceding siblings ...)
2002-09-17 13:13 ` Carl
@ 2002-09-17 16:01 ` Paul Furness
3 siblings, 0 replies; 6+ messages in thread
From: Paul Furness @ 2002-09-17 16:01 UTC (permalink / raw)
To: Paul Furness; +Cc: linux-newbie
Everyone,
Thanks for your help. Tee is exactly what I needed, and works perfectly.
P.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Exporting display
2002-09-17 12:45 ` Exporting display Abhijit Vijay
@ 2002-09-21 19:08 ` Kenneth Stephen
0 siblings, 0 replies; 6+ messages in thread
From: Kenneth Stephen @ 2002-09-21 19:08 UTC (permalink / raw)
To: Abhijit Vijay; +Cc: linux-newbie
On Tue, 17 Sep 2002, Abhijit Vijay wrote:
>
> 2. Execute "setenv DISPLAY ${REMOTEHOST}:0.0" after
> connecting to my linux machine through SSH
>
> 3. echo $REMOTEHOST gives me hughes08.biac.duke.edu
> (my Windows NT workstation)
>
> 4. echo $DISPLAY gives me hughes08.biac.duke.edu:0.0
>
> However, when I type xbiff& after connecting to my
> linux machine, I just get the process ID. The xbiff
> window does not show up!
>
Abhijit,
Did you try running it in the foreground first (without the
'&')? Some applications require a terminal to work atleast during
initialization and putting it in background mode may just stop the
process. The other thing to check for is whether your .xsession-errors
file shows any error messages. If it shows access denied type messages,
perhap you need to run xhost or an equivalent program on your NT machine.
Regards,
Kenneth
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-09-21 19:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-17 11:15 bash scripts creating log files Paul Furness
2002-09-17 12:45 ` Exporting display Abhijit Vijay
2002-09-21 19:08 ` Kenneth Stephen
2002-09-17 13:04 ` bash scripts creating log files Jos Lemmerling
2002-09-17 13:13 ` Carl
2002-09-17 16:01 ` Paul Furness
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox