Sponsored Content
Top Forums Shell Programming and Scripting Return multiple values using for loop in perl Post 302733667 by liyakathali on Tuesday 20th of November 2012 11:49:45 PM
Old 11-21-2012
Return multiple values using for loop in perl

I am using a for loop to copy files from say DIR1 and DIR2 to DIR3.I have to check whether files are copied from DIR1 and DIR2 and print the respective message.
Code:
@path=("$DIR1","$DIR2");
foreach (@path) {
$rc=system("cp $_/*xml $DIR3");
if ($rc == 0)
        {
print "Files were copied successfully from $_\n";
        }
else
        {
print "Files were not copied successfully from $_\n";
        }
 }

The above script works fine in perl but not working in perl web service.In perl web service the copy commands are executing but I am not able to print message for each directory individually.

Any help would be appreciated.

Thanks,
Liyakath.

Last edited by Franklin52; 11-21-2012 at 03:20 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl "system" cmd return values..

perl 5.6.1: when i try a "system" command(with if loops for $?), i get this: child exited with value 1 what is meant by this $? values and what does it meant if it returns 1?.. (0 Replies)
Discussion started by: sekar sundaram
0 Replies

2. Shell Programming and Scripting

Can $? return multiple values?

Hi, I have a script which does something like the below: execute_some_script.sh $arg1 $arg2 `exec-some-cmd` if then; do something else do something else fi However, during some cases, there is an error saying: line xxx: [: too many arguments at the line number which has... (5 Replies)
Discussion started by: laloo
5 Replies

3. Shell Programming and Scripting

Need Multiple Return Values

Hi, I need to retrun multiple values function errorFileCreation { echo "Before" return -1 "Siva"; echo "Aftyer" } echo ${?} - This can be used to getting first value. how can i get second one. Advance Thanks... Shiv (3 Replies)
Discussion started by: rsivasan
3 Replies

4. Shell Programming and Scripting

Using multiple values for single variable in a loop

Hello Guys, I have a small loop problem as below. I have 3 different values to be used while running the same script - va1="some-value1" va2="some-value2" va3="some-value3" Now I want to use these three variable values to be used for running the same command, like - while... (1 Reply)
Discussion started by: rockf1bull
1 Replies

5. Shell Programming and Scripting

unable to return multilple values in perl

hello friends, i have written one perl script.Which opens a file and search for some parameter's value and gets the status of these parameters. but while i am trying to return these value always i am getting false. Can any one please help me.. here is that function: =======================... (5 Replies)
Discussion started by: harpal singh
5 Replies

6. Shell Programming and Scripting

Perl: Problem in retaining values after each loop

use strict; use warnings; open (my $fhConditions, "<input1.txt"); #open input file1 open (my $fhConditions1, "<input2.txt");#open input file2 open (my $w1, ">output1"); open (my $w2, ">output2"); our $l = 10;#set a length to be searched for match our $site="AAGCTT";#pattern to be matched... (1 Reply)
Discussion started by: anurupa777
1 Replies

7. Shell Programming and Scripting

[SOLVED] UNIX FOR loop to read a variable with multiple values

Hi, I have a variable which stores file names as a result of find command. I need to delete all these files one by one, i.e. by a loop. Can anyone tell me how can it be done? The variable f2d has the file names like these abc.txt bcd.txt fff.txt gef.txt Now I have used a loop as... (12 Replies)
Discussion started by: jhilmil
12 Replies

8. Shell Programming and Scripting

Reading multiple values in while loop

I'm having trouble with a simple piece of code. IFS=, echo "1,2,3,4,5,6,7,8" | while read x y do echo "x=$x" echo "y=$y" done I'm hoping for x=1 y=2 x=3 y=4 . . . but I'm getting x=1 (3 Replies)
Discussion started by: sabbata
3 Replies

9. Shell Programming and Scripting

Returning and capturing multiple return values from a function

Hi I am pretty confused in returning and capturing multiple values i have defined a function which should return values "total, difference" i have used as #!/usr/bin/ksh calc() { total=$1+$2 echo "$total" diff=$2-$1 echo "$diff" } I have invoked this function as calc 5 8 Now i... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

10. Shell Programming and Scripting

[bash] wanted: function with a clean way for multiple return values

Hi, I have a small part of a project which is done as a bash script. bash was selected as an portability issue that works out of the box. In this script I have an exec shell-function, a wrapper around arbitrary commands. I want to have STDOUT, as an addon STDERR and the EXIT-CODE of a specified... (5 Replies)
Discussion started by: stomp
5 Replies
MELD(1) 						      General Commands Manual							   MELD(1)

NAME
meld - Visual diff and merge tool for the GNOME Desktop SYNOPSIS
meld [options] meld [options] FILE1 meld [options] DIR1 meld [options] FILE1 FILE2 [FILE3] meld [options] DIR1 DIR2 [DIR3] DESCRIPTION
Meld is a graphical diff viewer and merge application for the Gnome desktop. It supports 2 and 3-file diffs, recursive directory diffs, diffing of directories under version control (Arch, Bazaar, Codeville, CVS, Darcs, Git, Mercurial, Monotone, RCS), as well as the ability to manually and automatically merge file differences. OPTIONS
--auto-compare, -a Automatically compare all differing files on startup. --diff FILE1|DIR1 FILE2|DIR2 [FILE3|DIR3] Create a diff tab for the given files or directories. Note that "meld --diff FILE1 FILE2" is functionally equivalent to "meld FILE1 FILE2". However, the --diff argument can be given multiple times for one invocation of meld which allows the user to automatically initiate multiple diffs when meld starts. See examples below. --help, -h Print application help and usage. --LABEL=<label>, -L <label> Set application window title to <label>. --version Print application version and exit. EXAMPLES
meld Run meld without initiating a diff. meld FILE1 Initiate a diff between FILE1 and the version-controlled copy of FILE1. meld DIR1 Initiate a recursive diff between DIR1 and the version-controlled copy of DIR1. meld FILE1 FILE2 Initiate a diff between FILE1 and FILE2. meld FILE1 FILE2 FILE3 Initiate a 3-way diff between FILE1, FILE2, and FILE3. meld DIR1 DIR2 Initiate a recursive diff between directory DIR1 and DIR2. meld DIR1 DIR2 DIR3 Initiate a recursive 3-way diff between directory DIR1, DIR2, and DIR3. meld --diff FILE1 FILE2 --diff FILE3 FILE4 Initiate a diff between FILE1 and FILE2, and a separate diff between FILE3 and FILE4. BUGS
If you find a bug, please report it at https://bugzilla.gnome.org/buglist.cgi?product=meld or mail a description of the issue to meld- list@gnome.org. AUTHORS
See the AUTHORS text file in meld's source code (http://git.gnome.org/browse/meld/tree/AUTHORS). 26 Sept 2010 MELD(1)
All times are GMT -4. The time now is 09:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy