Sponsored Content
Top Forums Shell Programming and Scripting Redirect the output in a file and on screen Post 302524425 by dynamax on Monday 23rd of May 2011 09:42:40 AM
Old 05-23-2011
Redirect the output in a file and on screen

I am trying to get following result from the scipt I have. First time it generates the o/p in correct format. However if I run it again it appends to the existing file. I would like to see o/p on screen as well as save it in file. Everytime it should create new file.

## I/P file
0174
0175
0176
0177

## O/P file as well as on screen

create grp 0174, class=first;
new mem 14F4 to grp 0174;
new mem 14F5 to grp 0174;
new mem 14F6 to grp 0174;
new mem 14F7 to grp 0174;
new mem 14F8 to grp 0174;

Code:
 
     $grphd = `head -1 < $formember`;
     chomp ($grphd);
     $class="first";
     $memout = "/tmp/$class\_grp\_$grphd";
     $totcnt = `wc -l < $listmem`;
     $memcnt1 = 1;
     open (STDOUT, "| tee -ai $memout");
     open (FORMOUT,  $listmem) || die "Form Meta - Can't open $memdevlst: $!\n";
 while ($MEM= <FORMOUT>)
        {
if (($totcnt > 1) && ($metmcnt1 =~ 1))
        {
        chomp $MEM;
        print "create grp  $MEM, class=$class; \n";
        $memcnt1++;
        }
else
        {
        chomp $MEM;
        print "add dev $MEM to meta $grphd;\n";
        $memcnt1++;
        }
}
}
close (FORMOUT);
close (STDOUT);

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

redirect output to file?

Hi: I am currently working on a program which requires direct its ouput to a file here is an example ./proram arg_1 arg_2 when program ends all output will be arg_2 file Is that possible I am not a bad programmer, However I am stuck there. Can anyone give a hint? Thanks SW (1 Reply)
Discussion started by: slackware
1 Replies

2. UNIX for Dummies Questions & Answers

Redirect output to a file

Ahhhrrrggg I'm having a brain fart... I want to take the output of a command and redirect it to a file... This works.... $ man cp | cat >> copy_help but this doesn't keytool -help |cat >> keytool_help It just produces... these lines... more keytool_help ] ... ... (11 Replies)
Discussion started by: jimmyc
11 Replies

3. UNIX for Dummies Questions & Answers

redirect output to a file name

Hi all!! is possible to assign the output of some command to filename, i.e. grep_output.txt Otherwise, I want to open a new file which name is inside another, how can I do it? Thanks a lot! (7 Replies)
Discussion started by: csecnarf
7 Replies

4. Shell Programming and Scripting

How redirect standard output to a file

Hi guys, i have a script named purgeErrors.ksh, when i execute this script i need to redirect the output to a log file in the same directory, how can i do that ?? -- Aditya (5 Replies)
Discussion started by: chaditya
5 Replies

5. Shell Programming and Scripting

How to redirect output of ls to a file?

Hi All, I want to redirect only the file names to a new file from the ls -ltr directroy. how Can i do it. my ls -ltr output will be as below. -rwxr-xr-x 1 118 103 28295 Jul 26 2006 event.podl -rwxr-xr-x 1 118 103 28295 Jul 26 2006 xyz.podl I want my new file... (6 Replies)
Discussion started by: girish.raos
6 Replies

6. Shell Programming and Scripting

Redirect STDOUT & STDERR to file and then on screen

Dear all, redirecting STDOUT & STDERR to file is quite simple, I'm currently using: exec 1>>/tmp/tmp.log; exec 2>>/tmp/tmp.logBut during script execution I would like the output come back again to screen, how to do that? Thanks Lucas (4 Replies)
Discussion started by: Lord Spectre
4 Replies

7. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

8. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

9. Shell Programming and Scripting

Redirect STDOUT & STDERR to file and then on screen

Dear all, redirecting STDOUT & STDERR to file is quite simple, I'm currently using: Code: exec 1>>/tmp/tmp.log; exec 2>>/tmp/tmp.log But during script execution I would like the output come back again to screen, how to do that? Thanks Luc edit by bakunin: please use CODE-tags like the... (6 Replies)
Discussion started by: tmonk1
6 Replies

10. UNIX for Beginners Questions & Answers

Screen output to a file

Hi All, I am trying to out of shell script when i run it like sh /mypath/abc.sh ....a screen log should be generated whenever i input the values, when above the script prompt for values Regards Amarendra (3 Replies)
Discussion started by: amar1208
3 Replies
Mail::SPF::Mod::Redirect(3)				User Contributed Perl Documentation			       Mail::SPF::Mod::Redirect(3)

NAME
Mail::SPF::Mod::Redirect - SPF record "redirect" modifier class DESCRIPTION
An object of class Mail::SPF::Mod::Redirect represents an SPF record modifier of type "redirect". Constructors The following constructors are provided: new(%options): returns Mail::SPF::Mod::Redirect Creates a new SPF record "redirect" modifier object. %options is a list of key/value pairs representing any of the following options: domain_spec See "new" in Mail::SPF::Mod. new_from_string($text, %options): returns Mail::SPF::Mod::Redirect; throws Mail::SPF::ENothingToParse, Mail::SPF::EInvalidMod Creates a new SPF record "redirect" modifier object by parsing the string and any options given. Class methods The following class methods are provided: name: returns string Returns 'redirect'. name_pattern: returns Regexp Returns a regular expression that matches a modifier name of 'redirect'. precedence: returns real Returns a precedence value of 0.8. See "precedence" in Mail::SPF::Mod. Instance methods The following instance methods are provided: params See "params" in Mail::SPF::Mod. domain_spec: returns Mail::SPF::MacroString Returns the "domain-spec" parameter of the modifier. process($server, $request, $result): throws Mail::SPF::Result If no mechanism matched during the evaluation of the current SPF record, performs a recursive SPF check using the given SPF server and request objects and substituting the modifier's target domain name for the request's authority domain. The result of the recursive SPF check is then thrown as the result of the current record's evaluation. However, if the target domain has no acceptable SPF record, a "permerror" result is thrown. See RFC 4408, 6.1, for details. See Mail::SPF::Mod for other supported instance methods. SEE ALSO
Mail::SPF, Mail::SPF::Mod, Mail::SPF::Term, Mail::SPF::Record <http://www.ietf.org/rfc/rfc4408.txt> For availability, support, and license information, see the README file included with Mail::SPF. AUTHORS
Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org> perl v5.12.1 2010-07-05 Mail::SPF::Mod::Redirect(3)
All times are GMT -4. The time now is 06:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy