multiple redirections


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting multiple redirections
# 1  
Old 01-12-2006
multiple redirections

I have a line in my script which reads as

Code:
exec >> $LOG 2>&1

However I am required to get input from the user somewhere in between as follows.

Code:
read var?"Enter a value:" < /dev/tty

The execution of the script puts the prompt of the read command to the log file rather than the console, since I am redirecting the output in the begining.

I would like for the read prompt to appear in the console/display as well as go to the $LOG file.
After the user input is read from the console, the subsequent stdout and std err should go to the $LOG files. How can I achieve this? Please advise. Thanks

Jerardfjay Smilie

Last edited by jerardfjay; 01-12-2006 at 01:15 PM.. Reason: more info on the issue
# 2  
Old 01-12-2006
read var?"Enter a value:" < /dev/tty > /dev/tty 2>&1
# 3  
Old 01-12-2006
Quote:
Originally Posted by Perderabo
read var?"Enter a value:" < /dev/tty > /dev/tty 2>&1
Perderabo,

The above snippet has the same effect as before when I did not have the additional

Code:
> /dev/tty 2>&1

The prompt only appears in the log file and I do not see it on the screen.
Thanks

Jerardfjay
# 4  
Old 01-12-2006
Perderabo,

following your guideline I had changed the code to the following and it seems to work.

Code:
exec >> ./logfile 2>&1
while read line
do
        echo $line
        read var?"Enter a value:" < /dev/tty > `tty` 2>&1
        echo $var
done < testfile

Thanks for your input.
Jerardfjay
Smilie
# 5  
Old 01-12-2006
Just retried it. It continues to work for me. You must have a typo or something.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed parser behaving strange on replacing multiple words in multiple files

I have 4000 files like $cat clus_grp_seq10_g.phy 18 1002 anig_OJJ65951_1 ATGGTTTCGCAGCGTGATAGAGAATTGTTTAGGGATGATATTCGCTCGCGAGGAACGAAGCTCAATGCTGCCGAGCGCGAGAGTCTGCTAAGGCCATATCTGCCAGATCCGTCTGACCTTCCACGCAGGCCACTTCAGCGGCGCAAGAAGGTTCCTCG aver_OOF92921_1 ... (1 Reply)
Discussion started by: sammy777888
1 Replies

2. Shell Programming and Scripting

Removing carriage returns from multiple lines in multiple files of different number of columns

Hello Gurus, I have a multiple pipe separated files which have records going over multiple Lines. End of line separator is \n and records going over multiple lines have <CR> as separator. below is example from one file. 1|ABC DEF|100|10 2|PQ RS T|200|20 3| UVWXYZ|300|30 4| GHIJKL|400|40... (7 Replies)
Discussion started by: dJHa
7 Replies

3. Shell Programming and Scripting

Checking File record equal to multiple of 70 or nearest number to multiple of 70

Hello, I have a file with below content - Example 3 6 69 139 210 345 395 418 490 492 I would like the result as - Multiple of 70 or nearest number in the file less than the multiple of 70 69 139 (5 Replies)
Discussion started by: Mannu2525
5 Replies

4. Solaris

Solaris 10 audit, need to catch redirections

Hello, I've installed solaris audit on a Solaris 10 SPARC system. Latest patch 143962-04 is installed. My problem is that while I can catch all arguments and processes created, I cannot catch a redirection. ie cat /tmp/test.txt > /tmp/test2.txtCatches the first part but not the redirection.... (5 Replies)
Discussion started by: gowron
5 Replies

5. Shell Programming and Scripting

Reading multiple values from multiple lines and columns and setting them to unique variables.

Hello, I would like to ask for help with csh script. An example of an input in .txt file is below, the number of lines varies from file to file and I have 2 or 3 columns with values. I would like to read all the values (probably one by one) and set them to independent unique variables that... (7 Replies)
Discussion started by: FMMOLA
7 Replies

6. Shell Programming and Scripting

Grep from multiple patterns multiple file multiple output

Hi, I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command. Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns. Xargs -I {} grep... (3 Replies)
Discussion started by: Diya123
3 Replies

7. Shell Programming and Scripting

too many redirections error

When i try to run script in Linux, i get an error: ./MoveToHistory_ROAMING.sh: too many redirections What is the reason? Thank you. Please use code tags! (3 Replies)
Discussion started by: annar
3 Replies

8. Programming

Control multiple program instances - open multiple files problem

Hello. This shouldn't be an unusual problem, but I cannot find anything about it at google or at other search machine. So, I've made an application using C++ and QtCreator. I 've made a new mime type for application's project files. My system (ubuntu 10.10), when I right click a file and I... (3 Replies)
Discussion started by: hakermania
3 Replies

9. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

10. Shell Programming and Scripting

Error Redirections

Hi, I currently have a Unix script the calls the Teradata bteq utility. This bteq utility "takes" SQL commands from a file and writes the "output" to a log file the syntax for doing so was bteq<testscript.btq>testscript.log retval=$? if then echo "Failure in script execution -... (3 Replies)
Discussion started by: zainravi
3 Replies
Login or Register to Ask a Question