Non interactive command output using script command ?


 
Thread Tools Search this Thread
Operating Systems AIX Non interactive command output using script command ?
# 1  
Old 11-29-2010
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 doesn't have any options to record non-interactive command output.

Any ways to work around this - make AIX script command to save non-interactive command output ?

thanks
Vilius
# 2  
Old 11-29-2010
You could download the source for the gnu script and compile it. If redirection doesn't work it might be because output is getting sent to STDERR instead of STDOUT. Have you tried to do your redirect with 2> filename?
# 3  
Old 11-29-2010
No 2> doesn't work.

---------- Post updated at 09:21 AM ---------- Previous update was at 08:46 AM ----------

This is exactly my problem:
https://www.unix.com/unix-dummies-que...ly-script.html
# 4  
Old 11-29-2010
Have you tried running the script without redirecting the ouput to see what it is actually outputting? it seems to me that sftp may not me outputting what you want. My version of sftp doesn't have a progress bar. If you want a progress bar I would consider using scp instead.
# 5  
Old 11-29-2010
-$ sftp -b ./sftp_commands1 server1
sftp> progress
Progress meter enabled
sftp> mget *
Fetching /home/user1/file1 to file1
/home/user1/file1 100% 7 0.0KB/s 00:00
Fetching /home/user1/file2 to file2
/home/user1/file2 100% 7 0.0KB/s 00:00
Fetching /home/user1/file3 to file3
/home/user1/file3 100% 19 0.0KB/s 00:00
Fetching /home/user1/file4 to file4
/home/user1/file4 100% 7 0.0KB/s 00:00
Fetching /home/user1/file5 to file5
/home/user1/file5 100% 7 0.0KB/s 00:00
sftp> quit

$ sftp -b ./sftp_commands1 server1 >> log1
$ cat log1
sftp> progress
Progress meter enabled
sftp> mget *
Fetching /home/user1/file1 to file1
Fetching /home/user1/file2 to file2
Fetching /home/user1/file3 to file3
Fetching /home/user1/file4 to file4
Fetching /home/user1/file5 to file5
sftp> quit


As you can see progress/status lines are gone.

V

Last edited by vilius; 11-29-2010 at 04:30 AM..
# 6  
Old 11-29-2010
That is wierd. maybe the program is writing the progress directly to you tty instead of STDOUT. But if that were the case you should still see those messages...

Have you tried using tee?

Code:
command | tee -a $LOGFILE

# 7  
Old 11-29-2010
tee behaves the same way as redirect operators.

V
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help make pkgadd command Non-Interactive

i use this command to make pkgadd non-interactive. Command1: echo | sudo /usr/sbin/pkgadd -n -a /u/base/admin -r silent.txt -d /tmp/dbs.pkgThis works fine if i run it as root user but when i run it with non-root user it prompts me for the password and then executes successfully thus making it... (9 Replies)
Discussion started by: mohtashims
9 Replies

2. Shell Programming and Scripting

Insert title as output of command to appended file if no output from command

I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place. What I need The following command is placed at the prompt: TICLI... (4 Replies)
Discussion started by: jbrass
4 Replies

3. UNIX for Dummies Questions & Answers

Set Command to output a log of every command executed in the script

Hi Guys, I like to output every command executed in the script to a file. I have tried set -x which does the same. But it is not giving the logs of the child script which is being called from my script. Is there any parameters in the Set command or someother way where i can see the log... (2 Replies)
Discussion started by: mac4rfree
2 Replies

4. 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

5. Shell Programming and Scripting

Shell script using an interactive command

Hello experts, I have a to write script for monitoring, the script would use a command and I plan to write the script as follows while true do command -arg sleep 2 clear done The output would be set up on a screen for monitoring. However the issue is that the command used in... (2 Replies)
Discussion started by: maverick_here
2 Replies

6. UNIX for Dummies Questions & Answers

passing command output from one command to the next command in cshell

HI Guys, I hope you are well. I am trying to write a script that gets executed every time i open a shell (cshell). I have two questions about that 1) I need to enter these commands $ echo $DISPLAY $ setenv $DISPLAY output_of_echo_$display_command How can i write a... (2 Replies)
Discussion started by: kaaliakahn
2 Replies

7. Shell Programming and Scripting

How to make command line interactive?

I have a file with stats for different month, I use the cat and grep combination to search for different month. cat <file> | grep "April" cat <file> | grep "May" cat <file> | grep "June" etc. How do you make this command interactive. So that I can give the values for the search. Thanks... (7 Replies)
Discussion started by: purelltab
7 Replies

8. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies

9. UNIX for Advanced & Expert Users

SU command in non interactive mode

Can i run the SU command in a non interactive mode. What i want to do is to pass the username and the password as commandline or batch parameters. Please let me if its possible and how to pass them. A sample file will be appreciated. Thanks, (6 Replies)
Discussion started by: rohitag
6 Replies

10. Shell Programming and Scripting

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... (6 Replies)
Discussion started by: MizzGail
6 Replies
Login or Register to Ask a Question