Print info in console or not judged by variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print info in console or not judged by variable
# 1  
Old 09-28-2014
Print info in console or not judged by variable

I have a code fragment

Code:
#dosomething 
(
#do many things 
) |tee -a zzz.log 
#dosomething

I want a varialbe var

if var =1, print the info in (#do many things ) to console, if var=0, not print the info to console
# 2  
Old 09-28-2014
At the top of your script:

Code:
[ "$VAR" -eq 0 ] && exec 1> /dev/null

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print file info with FFprobe?

Hello, I have many mp4 files inside a folder and I need to write stream info of each files. Below script creates txt files but inside of each file is empty. #!/bin/bash for video in *.mp4; do base="${video%.mp4}" ffprobe -i "$base".mp4 > "$base".txt; done exit 0 When I run... (2 Replies)
Discussion started by: baris35
2 Replies

2. Shell Programming and Scripting

To print value for a $variable inside a $variable or file

Hi guys, I have a file "abc.dat" in below format: FILE_PATH||||$F_PATH TABLE_LIST||||a|b|c SYST_NM||||${SRC_SYST} Now I am trying to read the above file and want to print the value for above dollar variables F_PATH and SRC_SYST. The problem is it's reading the dollar variables as... (5 Replies)
Discussion started by: abcabc1103
5 Replies

3. Shell Programming and Scripting

How to print warning messages on console when we use exec command?

I am having script in which for logging I am using exec command. I am calling another script/program through this script which is designed for another user id. So, After running script it is giving warning message as "This program has been designed for another user id. Please press Enter to... (6 Replies)
Discussion started by: VSom007
6 Replies

4. Shell Programming and Scripting

awk print variable then fields in variable

i have this variable: varT="1--2--3--5" i want to use awk to print field 3 from this variable. i dont want to do the "echo $varT". but here's my awk code: awk -v valA="$varT" "BEGIN {print valA}" this prints the entire line. i feel like i'm so close to getting what i want. i... (4 Replies)
Discussion started by: SkySmart
4 Replies

5. Shell Programming and Scripting

Event logging to file and display to console | tee command is not able to log all info.

My intention is to log the output to a file as well as it should be displayed on the console > I have used tee ( tee -a ${filename} ) command for this purpose. This is working as expected for first few outputs, after some event loggin nothing is gettting logged in to the file but It is displaying... (3 Replies)
Discussion started by: sanoop
3 Replies

6. Shell Programming and Scripting

Redirecting output that was redirected to variable and console

Hi all, I would like to store the output of a command in a variable and output it to the console at the same time. This is working fine using the following construct var=`command | tee /dev/tty` I use this in some scripts to display the output of the command on the console and, at the same... (2 Replies)
Discussion started by: script_man
2 Replies

7. Solaris

unable to load console info in SUNMC 4.0

Hi all, unable to load console info in SUNMC 4.0 in alarm it is giving error info i.e..Agent on host (.....),1161 port not responding. Iam using M9000 server solaris 10 plz try to solve the problem Regards spandhan (0 Replies)
Discussion started by: spandhan
0 Replies

8. Infrastructure Monitoring

unable to load console info in SUNMC 4.0

hi all, unable to load console info in SUNMC 4.0 in alarm it is giving error info i.e..Agent on host (.....),1161 port not responding. plz try to solve the problem Regards spandhan (5 Replies)
Discussion started by: spandhan
5 Replies

9. Shell Programming and Scripting

Print out loop index on the console after executing each sybase DB query

Hello Guys, Well, using shell script, I'm doing loop on DB query as below: isql -Usa -Ptest -I /opt/sybase/interfaces << EOF use testdb go declare @i int select @i = 1 while(@i <= 5) begin Insert into TEST values (@i,"Test","TestDesc") select @i = @i + 1 end go EOF The Issue... (2 Replies)
Discussion started by: Alaeddin
2 Replies

10. UNIX for Dummies Questions & Answers

gettting disk info from console

Hi all, can someone tell me the easiest was to get disk info from a console. I manage headless servers, and would like to collect the specs on hard drives installed without looking it up through Sun. The boot messages only tell me the size/name e.g. 'Sun36G' I want to know the rotation... (1 Reply)
Discussion started by: mintzy
1 Replies
Login or Register to Ask a Question