Sayed, Irfan (Irfan) wrote: > Hi, Hello,
> I am executing following perl script > > # perl script to change the hostname of every replica / VOB > > use strict; > > my $CT = "ct"; > > my @vob_list = `$CT lsvob -s`; Assuming that 'ct lsvob -s' outputs the list: \openssl_openssl \openssl_openssl_rel \gatne_tut_input_vob \gatne_tut_tools_vob \bt_rel etc. Then @vob_list would contain the data: ( "\openssl_openssl\n", "\openssl_openssl_rel\n", "\gatne_tut_input_vob\n", "\gatne_tut_tools_vob\n", "\bt_rel\n", "etc.\n" ) You should remove the newlines from the data: chomp( my @vob_list = `$CT lsvob -s` ); > print "Following are the VOBs / Replicas whose hostname needs to be > change \n"; > > print @vob_list; > > foreach my $a (@vob_list) > { > print $a; > `$CT lsreplica -fmt %[master]p\n -invob $a`; The first thing that happens is that perl interpolates this as a double quoted string so $CT is replaced with 'ct' and \n is replaced with the newline character and $a is replaced with the current element of @vob_list (for example "\openssl_openssl\n") and the resulting string ('ct lsreplica -fmt %[master]p\012 -invob \openssl_openssl\n') is passed to the shell which may or may not interpolate '%', '[', '\o' and '\n' (depending on the shell and the current settings for that shell.) (If '\o' is not a valid shell escape sequence it will be converted to 'o'.) Also when a shell sees the newline character it usually signifies the end of input for that line. See also: perldoc -q "using backticks in a void context" > } > > If i print the value of $a then the output is fine Try printing: print "$CT lsreplica -fmt %[master]p\n -invob $a"; Because that is (probably) what the shell will see. > but the moment i execute this command > > `$CT lsreplica -fmt %[master]p\n -invob $a`; > > it is giving me following error. > > cleartool: Error: Unable to determine VOB for pathname ".". Try it like this: system( $CT, 'lsreplica', '-fmt', '%[master]p\n', '-invob', $a ) == 0 or die "system $CT failed: $?"; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>