"exec" command. Stopoutput to file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting "exec" command. Stopoutput to file.
# 1  
Old 08-06-2012
"exec" command. Stopoutput to file.

I have a script (ksh, Linux) which is about 500 lines and this is only a small requirement. Below is an example of my requirement.
Code:
 
FunctionThis(){
  echo "You are in this. Goes to log"
}
FunctionThat(){
  echo "You are in That. Goes to log"
}
FunctionScreen(){
  echo "You are in Screen. Goes to screen."
  echo "Press ^c to exit"
  sleep 60
}
################
# Main
################
exec > Outlog1.txt 2>&1
FunctionThis
FunctionThat
exec > > 2>&1
FunctionScreen

1. Now all the outputs are going to .log file.
2. I want "FunctionScreen" output to be on the screen.
Not into the log file.
That is, I thought
HTML Code:
exec > > 2>&1
will disable writing to log file.
Can you help me please?
# 2  
Old 08-06-2012
If you need to restore the default stdout destination, you will need to save it before the first exec redirects it.

Regards,
Alister

Last edited by alister; 08-06-2012 at 06:06 PM.. Reason: Typo
# 3  
Old 08-06-2012
Save what? Can you please tell me how to do it?
# 4  
Old 08-06-2012
See Example 20-2 @ Using exec

Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

exec perl in expect script yields "invalid command"

I'm trying to execute something like this: exec perl -i -pe 's/\015/\012/g' '${file}' in my expect script and I get: error "invalid command name \"perl\". however, if I run perl -i -pe 's/\015/\012/g' "/Users/Shared/menu-items.txt" directly in my terminal, it runs fine. I'm an... (4 Replies)
Discussion started by: dpouliot
4 Replies

4. Shell Programming and Scripting

A question on "exec" command

The following is my bash script ----------------------- #!/bin/bash exec myscript "$@" ----------------------- When invoked, the script "myscript" in the exec command is using the file "/usr/bin/diff" But, I want the script "myscript"to use the file "/home/bin/diff" How can I... (1 Reply)
Discussion started by: bsoo
1 Replies

5. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

9. UNIX for Dummies Questions & Answers

Using "find" and "-exec rm" ... Just no luck :(

Hi All, Ok, so I'm fairly new to Unix, but would like to think I'm grasping things fairly ok (Well until now ;) ), BUT with this one I'm going in circles ... LOL .. really can't work out why? So sorry for this post if it seems a little "dumb" .. But here goes. In short I'd like to achieve the... (55 Replies)
Discussion started by: Dean Rotherham
55 Replies

10. UNIX for Dummies Questions & Answers

No utpmx entry: you must exec "login" from lowest level "shell"

Hi I have installed solaris 10 on an intel machine. Logged in as root. In CDE, i open terminal session, type login alex (normal user account) and password and i get this message No utpmx entry: you must exec "login" from lowest level "shell" :confused: What i want is: open various... (0 Replies)
Discussion started by: peterpan
0 Replies
Login or Register to Ask a Question