Sponsored Content
Top Forums Shell Programming and Scripting Perl: combine Backtick & system() I/O operation? Post 302425820 by durden_tyler on Sunday 30th of May 2010 02:11:38 PM
Old 05-30-2010
Quote:
Originally Posted by jeffw_00
...
I want to re-direct all the output from the command to a file (@result = `$cmd`), but I ALSO want the results to be displayed on the screen (system("$cmd");
...
Any easy way to do this in perl?
...
You may want to check out the "Tee" module - Perl's implementation of the "tee" command.

Code:
$ 
$ # let's assume you want to run the command "seq 1 10" from within Perl
$ perl -le 'use Tee; tee("seq 1 10", "testfile.out")'
1
2
3
4
5
6
7
8
9
10
$ 
$ cat testfile.out
1
2
3
4
5
6
7
8
9
10
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

Multi operation system in one pc.

Does anyone can write a thread to teach me how to install Windows 2000, RH Linux, and FreeBSD unix in one machine step by step? Or someone's already done with this topic? (1 Reply)
Discussion started by: HOUSCOUS
1 Replies

2. Ubuntu

where can i get the unix operation system?

I am a stranger here ,where can i get the operation for free.thank you! (2 Replies)
Discussion started by: tcb3210
2 Replies

3. UNIX for Dummies Questions & Answers

what does the operation '>&' mean in a shell script

hi, all, i saw a syntax like this usr/local/mpiexec -np 8 /home/XXXX/program_exe >& ./temp/out the output will be put into ./temp/out. I want to know the meaning of the operation symbol '>&'. Thanks (3 Replies)
Discussion started by: cy163
3 Replies

4. Shell Programming and Scripting

combine two perl lines into a single perl command

Hi Everyone, i have a string 00:44:40 so: $tmp=~ s/://gi; $tmp=~s/({2})({2})({2})/$1*3600+$2*60+$3/e; the output is 2680. Any way to combine this two lines into a single line? Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies

5. Shell Programming and Scripting

Perl: Backtick Errors

When trying to use backticks for system commands, is there a way to read the error messages if a command doesn't execute properly? I have no problem getting the results if the command is properly executed. Ex. my @result = `dir`; foreach my $line (@result) { print "Result = $line";... (2 Replies)
Discussion started by: kooshi
2 Replies

6. Linux

commands of linux operation system

Am actually am new to the linux operating system and knda wana knw more about it.Please could u help me with some commands so i can start with that first.Really need your help (5 Replies)
Discussion started by: GODBLESSME
5 Replies

7. UNIX for Dummies Questions & Answers

system calls and atomic operation

Are system calls atomic operations? Is a system call can be interrupted? (2 Replies)
Discussion started by: vistastar
2 Replies

8. Shell Programming and Scripting

Enter third column & Perform Operation

I am trying to enter a third column in this file, but the third column should that I call "Math" perform a some math calculations based on the value found in column #2. Here is the input file: Here is the desired output: Output GERk0203078$ Levir Math Cotete_1... (5 Replies)
Discussion started by: Ernst
5 Replies

9. AIX

Monitoring AIX with System Center Operation Manager 2007 R2

I can get my AIX servers to show up in SCOM but I'm struggling with running personal scripts and have the result of these scripts show up in SCOM. I'm currently using BigBrother and I've written some scripts for BB. I would like to convert these scripts to something that can be used in SCOM. ... (0 Replies)
Discussion started by: petervg
0 Replies

10. Shell Programming and Scripting

Help me to perform count & group by operation in shell scripting?

Hi All, I want to display the distinct values in the file and for each distinct value how may occurance or there. Test data: test1.dat 20121105 20121105 20121105 20121105 20121106 20121106 20121106 20121105 I need to display the output like Output (2 Replies)
Discussion started by: bbc17484
2 Replies
openipmicmd(1)						     An IPMI Command Interface						    openipmicmd(1)

NAME
openipmicmd - An IPMI Command Interface SYNOPSIS
openipmicmd [-k entry-to-execute] <connection parms> DESCRIPTION
The openipmicmd program allows a user to execute direct IPMI commands. It can work with direct interface with the OpenIPMI driver or with IPMI LAN interfaces. OPTIONS
-k entry-to-execute Execute a single command an exit. <connection parms> The parameters for the connection depend on the connection type. These are all described in openipmi_conparms (7) COMMANDS
Once up, you can execute commands in the user interface. Note that commands and responses are asynchronous, you issue a command and the interface returns immediately. When the response comes back, it will be dumped on your console. That's a little strange looking, but IPMI is asynchronous underneath. Note that the -k option is synchronous, it will wait for the response or a timeout before returning. 0f lun netfn cmd [data1 [data2 ...]] Send a command to the BMC you are connected to. channel [ipmb] IPMB-addr lun netfn [seq] cmd [data1 [data2 ...]] Send a command to a device on the IPMB bus. The "ipmb" string is optional. The seq must be provided if the netfn is a response (an odd number). It must be the same sequence number that came in on the command in the "Command Sequence = seq" part of the command. channel 00 IPMB-addr lun netfn cmd [data1 [data2 ...]] Send a broadcast command to a device on the IPMB bus. channel lan handle remote-swid local-swid lun netfn cmd [data1 [data ...]] Send a command to a device over a LAN channel. Note that this not the same as a LAN connection. This sends a message through a local BMC to a remote system that is hooked up with a LAN connection. test_lat count command Executes the given commands (one of the previous commands) count times and gives the average time per command to execute. Note that "count" is hexadecimal. help Display some help. regcmd netfn cmd Register to receive the given command. If the driver receives an external command, it will print it out. This only works with sys- tem interface connections, it will not work on LAN connections. unregcmd netfn cmd Remove a command registration. SEE ALSO
ipmi_ui(1), ipmilan(8), openipmi_conparms(7) KNOWN PROBLEMS
The asynchronous nature of the program can be annoying. AUTHOR
Corey Minyard <cminyard@mvista.org> OpenIPMI 05/13/03 openipmicmd(1)
All times are GMT -4. The time now is 03:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy