Capture output from interactive script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capture output from interactive script
# 1  
Old 04-04-2002
Question Capture output from interactive script

I have written a menu driven script to walk users through bringing up and down an application process.
Sometimes the user tells me the script does not work taking the application down, but he can't recall seeing an error message.

Is there a way to capture std out and stderr out from an interactive script as well as have it still interacting with the user? I can set -x to trace a script, but the output shows up to the user too..
# 2  
Old 04-04-2002
Try the script command. It will record everything...all i/o to or from the terminal.
# 3  
Old 04-04-2002
I don't want the trace commands showing up for the user, I need them captured to a file so I can look at them.
No way to do this?
# 4  
Old 04-04-2002
I'm not sure exactly what it is that you want here.

But trace output goes to stderr. You can capture stderr to a file like this...

exec 2>errorlog
set -x

That will send all stderr to the file. If you have some stderr stuff that you want the user to see, you will need to handle stderr for each command that might send something to stderr:

command 2>/dev/tty
# 5  
Old 04-04-2002
Ok. this is doing what I want to a point. I am getting my trace commands to the errrorlog and not to the user executing the script.

Inside this menu script, one of the options is to show the current status of the system.
When I issue the command, it only goes to the errorlog, but not to the user. (I'm sure this is simple, please bear with me)....
I tried
command >/dev/tty and
command 2>/dev/tty

but its still putting the response into the errorlog only.
# 6  
Old 04-04-2002
I don't really understand that, I would have expected one of those to work. But here is a sledge hammer approach...

( set +x ; exec >&- 2>&- >/dev/tty 2>&1 ; command )

This fires up a subshell, closes that trace file, resets sdtout and stderr to be /dev/tty and only then invokes the command.
# 7  
Old 04-04-2002
I found another way around that one issue, but this is working for me. ! thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture output from expect script

Hi I am new to Expect scripting. I have to connect to a remote server and capture the output. Here I need output of " send "list registered\r"" to be stored in a file. but after execution, /tmp/capture.txt is of 0 byte #!/usr/bin/expect spawn ssh abc@10.10.10.10 -p 5022 expect... (2 Replies)
Discussion started by: bns928
2 Replies

2. Shell Programming and Scripting

Capture Output from an "Interactive" Command?

Hello All, I was wondering how to capture the output of an "interactive" command that is run...? I think "interactive" is the word I'm looking for. For example, commands like "top" and "iftop"... The One I'm trying to work with is "iftop". When you run "iftop" from the command line it begins... (2 Replies)
Discussion started by: mrm5102
2 Replies

3. Solaris

How to capture Output of truus command

Hi I want to check if some process is sleeping. I can see that in truss -p <pid> I want to capture output and check that output if proces sis sleeping. Please suggest way to capture output of truss command or other way to check if process is sleeping (1 Reply)
Discussion started by: ankush_mehra
1 Replies

4. AIX

Non interactive command output using script command ?

Hello, Script command helps to save command output to file. (Redicection doesn't work in this case). Besides interactive shell 'recording', Linux script command has "-c" option which allows to record output of some non-interactive command. The problem is that AIX script command variant... (6 Replies)
Discussion started by: vilius
6 Replies

5. Shell Programming and Scripting

Script to capture snoop output

Hi Everyone :), Need your advice as I'm new to UNIX scripting.. I'm trying to write a script to capture snoop output for 5 minutes for every hour for 24 hours. To stop snoop, I need to press Control-C to break it. This is what I got so far, but now I'm stuck! :confused: The script: # cat... (2 Replies)
Discussion started by: faraaris
2 Replies

6. Homework & Coursework Questions

How to write script that behaves both in interactive and non interactive mode

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (8 Replies)
Discussion started by: rits
8 Replies

7. Homework & Coursework Questions

Help with Interactive / Non Interactive Shell script

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (1 Reply)
Discussion started by: rits
1 Replies

8. Shell Programming and Scripting

Capture Shell Script Output To A File

Hi, I am running a shell script called dbProcess.sh which performs shutdown and startup of various Oracle instances we have.At the time of execution the script produces the following output to the command line window $./dbProcess.sh stop #### Run Details ###### Hostname : server-hop-1... (4 Replies)
Discussion started by: rajan_san
4 Replies

9. Shell Programming and Scripting

script to capture certain output

Hi All, I want to create a script that capture only Date & Time, Current CPU % usage, Disk % usage, Mem % usage and Top process based on this output; Data Collected: 05/17/08 17:19:49 Refresh Interval: 600 seconds GlancePlus Started/Reset: 05/17/08 08:19:45 B3692A GlancePlus... (18 Replies)
Discussion started by: fara_aris
18 Replies

10. Shell Programming and Scripting

Capture scp output

I have a simple script that uses scp to copy some files from one server to another. I want to capture the files that are copied but simple redirection to a file does not work. So I want to capture this output from the scp command in a log file. -bash-3.00$ scp -pr /export/jumpstart/Files... (7 Replies)
Discussion started by: Tornado
7 Replies
Login or Register to Ask a Question