Sponsored Content
Full Discussion: Perl system fuction with
Top Forums Shell Programming and Scripting Perl system fuction with Post 302355960 by thegeek on Thursday 24th of September 2009 07:36:42 AM
Old 09-24-2009
You have new line in $location.

Kindly chomp it before giving it as argument.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Get Oracle fuction return value in a variable

Hi All, :confused: I have the following code. var=' ' sqlplus user/pass@DB <<EOF whenever sqlerror exit 1 select package.func() into $var from dual; EOF echo $var But, this code does not work to display the value returned by the oracle function. Do we have to bind variables before... (3 Replies)
Discussion started by: rahulrathod
3 Replies

2. Shell Programming and Scripting

perl - system command

Can this be done without using te system command? I have a directory with a large number of files in it, but I am interested in only the 8 most recent. The directory looks like -rw-rw-rw- 1 adsm adsm 13412 Sep 22 08:31 events_dump_09222005.csv.gz -rw-rw-rw- 1 adsm adsm ... (5 Replies)
Discussion started by: reggiej
5 Replies

3. Programming

about memset fuction

Dear all, In my code,i am planning to use memset function to re-initialise an array before populating it everytime. Will using memset function be an overload to the program? (3 Replies)
Discussion started by: ranj@chn
3 Replies

4. Shell Programming and Scripting

Need Help w/PERL system command

Hi, I'm wanting to run an nslookup, dig or whatever to check for the existence of a printer. The PERL script will display the results on the screen, but I can't figure out how to capture the result & test the value. Any ideas will be greatly appreciated!!! Thank You (1 Reply)
Discussion started by: lorik
1 Replies

5. UNIX for Advanced & Expert Users

awk and fuction (recursion) !! Urgent !!

Hey all, :D Could you please check following way of writing awk is correct or not ??? ----------------------------------------------------------- ----------------------------------------------------------------- Its recursion being called. tempgrep.txt has : 462948 1311040 880922... (12 Replies)
Discussion started by: varungupta
12 Replies

6. Shell Programming and Scripting

fuction return in perl

Hi All, I have a perl script(1.pl) that calls a c function defined in another file sample.c #!/usr/bin/perl my $re = 1; my @s = `/home/PERL_SCRIPTING/Rough/sample pline $re 10`; print "$_" foreach(@s); The sample.c is as bwlow: # include <stdio.h> int pline(int, int);... (4 Replies)
Discussion started by: jisha
4 Replies

7. Shell Programming and Scripting

Perl variables in exec or system

I am new in Perl. I am working in simple script and the varibles are working well outside the exec or system command. but they don't work as parameters to exec or system command. The script is attached. please help. (8 Replies)
Discussion started by: ahmed_zaher
8 Replies

8. Shell Programming and Scripting

System variables in Perl

Hi I'm new to Perl and the forum. I've done a quick search on my question but I didn't see an answer. I sincerely apologize if this question has been asked. I'm trying to have my perl scrip recognize system variable $USER such that: my $test_path = "/temp/\$USER/g03/Gau-11097.EIn"; open... (2 Replies)
Discussion started by: jhbamboo
2 Replies

9. Shell Programming and Scripting

Perl copy vs system cp

What are the pros & cons, if any, between using Perl's copy module vs OS's system cp, for copying a file to another directory? Or are they exactly the same? 1) Perl's File::Copy module, as in copy ($filename, $dest_path) or die "ERROR: Cannot copy\n"; 2) if (system ("cp $filename,... (3 Replies)
Discussion started by: slchin
3 Replies

10. Shell Programming and Scripting

UNIX date fuction - how to deduct days from today's date

Hi, One of my Unix scripts needs to look for files coming in on Fridays. This script runs on Mondays. $date +"%y%m%d" will give me today's date. How can I get previous Friday's date.. can I do "today's date minus 3 days" to get Friday's date? If not, then any other way?? Name of the files is... (4 Replies)
Discussion started by: juzz4fun
4 Replies
IO::Capture::Stdout(3pm)				User Contributed Perl Documentation				  IO::Capture::Stdout(3pm)

NAME
IO::Capture::Stdout - Capture any output sent to STDOUT SYNOPSIS
# Generic example (Just to give the overall view) use IO::Capture::Stdout; $capture = IO::Capture::Stdout->new(); $capture->start(); # STDOUT Output captured print STDOUT "Test Line One "; print STDOUT "Test Line Two "; print STDOUT "Test Line Three "; $capture->stop(); # STDOUT output sent to wherever it was before 'start' # In 'scalar context' returns next line $line = $capture->read; print "$line"; # prints "Test Line One" $line = $capture->read; print "$line"; # prints "Test Line Two" # move line pointer to line 1 $capture->line_pointer(1); $line = $capture->read; print "$line"; # prints "Test Line One" # Find out current line number $current_line_position = $capture->line_pointer; # In 'List Context' return an array(list) @all_lines = $capture->read; # More useful example 1 - "Using in module tests" # Note: If you don't want to make users install # the IO::Capture module just for your tests, # you can just install in the t/lib directory # of your module and use the lib pragma in # your tests. use lib "t/lib"; use IO::Capture::Stdout; use Test::More; my $capture = IO::Capture::Stdout->new; $capture->start # execute with a bad parameter to make sure get # an error. ok( ! $test("Bad Parameter") ); $capture->stop(); DESCRIPTION
The module "IO::Capture::Stdout", is derived from the abstract class "IO::Capture". See IO::Capture. The purpose of the module (as the name suggests) is to capture any output sent to "STDOUT". After the capture is stopped, the STDOUT filehandle will be reset to the previ- ous location. E.g., If previously redirected to a file, when "IO::Capture->stop" is called, output will start going into that file again. Note: This module won't work with the perl function, system(), or any other operation involving a fork(). If you want to capture the output from a system command, it is faster to use open() or back-ticks. my $output = `/usr/sbin/ls -l 2>&1`; METHODS
new o Creates a new capture object. o An object can be reused as needed, so will only need to do one of these. o Be aware, any data previously captured will be discarded if a new capture session is started. start o Start capturing data into the "IO::Capture" Object. o Can not be called on an object that is already capturing. o Can not be called while STDOUT tied to an object. o "undef" will be returned on an error. stop o Stop capturing data and point STDOUT back to it's previous output location I.e., untie STDOUT read o In Scalar Context o Lines are read from the buffer at the position of the "line_pointer", and the pointer is incremented by one. $next_line = $capture->read; o In List Context o The array is returned. The "line_pointer" is not affected. @buffer = $capture->read; o Data lines are returned exactly as they were captured. You may want to use "chomp" on them if you don't want the end of line charac- ter(s) while (my $line = $capture->read) { chomp $line; $cat_line = join '', $cat_line, $line; } line_pointer o Reads or sets the "line_pointer". my $current_line = $capture->line_pointer; $capture->line_pointer(1); SUB-CLASSING Adding Features If you would like to sub-class this module to add a feature (method) or two, here is a couple of easy steps. Also see IO::Capture::Over- view. 1 Give your package a name package MyPackage; 2 Use this "IO::Capture::Stdout" as your base class like this: package MyPackage; use base qw/IO::Capture::Stdout/; 3 Add your new method like this package MyPackage; use base qw/IO::Capture::Stdout/; sub grep { my $self = shift; for $line ( } See Also IO::Capture::Overview IO::Capture IO::Capture::Stderr AUTHORS
Mark Reynolds reynolds@sgi.com Jon Morgan jmorgan@sgi.com COPYRIGHT
Copyright (c) 2003, Mark Reynolds. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.8.8 2007-07-30 IO::Capture::Stdout(3pm)
All times are GMT -4. The time now is 01:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy