Hi; I have two perl scripts. Once calls the other via a ClearCase setview context (like a subshell).
The problem: The current scripts do not handle filenames that have parens properly and the parens are obviously mishandled by the shell. The overall goal: What I'm really trying to do is to generate a list of all flat files and/or symlinks that are part of a specified ClearCase label so that I can generate a tarball composed of those files/symlinks. This should be a trivial exercise, but Rational/IBM has made it more challenging than it needs to be, but that is a topic for another mailing list :-( example filenames that are problematic: /very_long_path/lang/menu_chinese(taiwan)_taiwan.950.vim /very_long_path/lang/menu_chinese(gb)_gb.936.vim The error message: sh: -c: line 1: syntax error near unexpected token `(' sh: -c: line 1: `/usr/atria/bin/cleartool describe \ /very_long_path/lang/menu_chinese(taiwan)_taiwan.950.vim | \ /bin/grep specified_label' sh: -c: line 1: syntax error near unexpected token `(' sh: -c: line 1: `/usr/atria/bin/cleartool describe \ /very_long_path/lang/menu_chinese(gb)_gb.936.vim | \ /bin/grep specified_label' The scripts: try10.pl: *************************** #!/usr/bin/perl use strict; use warnings; use diagnostics; my $cmd; my $date = "/bin/date"; my $label = "specified_label"; my $ct = "/usr/atria/bin/cleartool"; my $dts = `$date +%Y%m%d_%H%M%S`; chomp $dts; my $view = "kwolcott.etram.test_view_" . $dts; $cmd = $ct . " mkview -tag " . $view . " /opt/views/." . $view . ".vws"; print $cmd . "\n"; system ($cmd); my $cfg_spec = "/tmp/cfg_spec_" . $dts; open (CFG_SPEC, ">" . $cfg_spec) or die "ERROR: Unable to open " \ . $cfg_spec . " for writing, $!"; print CFG_SPEC "element * " . $label . "\n"; print CFG_SPEC "element * main/LATEST\n"; close (CFG_SPEC); $cmd = $ct . " setcs -tag " . $view . " " . $cfg_spec; print $cmd . "\n"; system ($cmd); $cmd = $ct . " catcs -tag " . $view; print $cmd . "\n"; system ($cmd); $cmd = $ct . " setview -exec ~/ct_find_stuff/try10_body.pl " . $view; print "\nThis may take quite some time...\n"; print $cmd . "\n"; system ($cmd); print "\nDone\n"; *************************** try10_body.pl ********************************************** #!/usr/bin/perl use strict; use warnings; use diagnostics; my $count; my $date = "/bin/date"; my $dts = `$date +%Y%m%d_%H%M%S`; chomp $dts; my $grep = "/bin/grep"; my $label = "specified_label"; my $ct = "/usr/atria/bin/cleartool"; my $log = "/tmp/try10_" . $dts . ".log"; my $tarball_input_file = "/tmp/tarball_input_file_" . $dts; my $unassociated = "/tmp/unassociated_" . $dts . ".log"; my $error_log = "/tmp/error_log_" . $dts . ".log"; my $cmd = $ct . " find -avobs -nxname -visible -follow -version \ lbtype_sub'(" . $label . ")' -print"; print $cmd . "\n"; open (LOG, ">" . $log) or die "ERROR: Unable to open " . $log . " for \ writing, $!"; open (ERRORS, ">" . $error_log) or die "ERROR: Unable to open " . \ $error_log . " for writing, $!"; open (TARBALL_INPUT_FILE, ">" . $tarball_input_file) or die "ERROR: \ Unable to open " . $tarball_input_file . " for writing, $!"; open (UNASSOCIATED, ">" . $unassociated) or die "ERROR: Unable to \ open " . $unassociated . " for writing, $!"; open (PIPE, $cmd . " 2>&1 |") or die "ERROR: Unable to execute " . \ $cmd . " via a command pipe, $!"; while (my $line = <PIPE>) { $count++; print "." unless ($count % 100); chomp $line; print LOG $line . "\n"; if ($line =~ m/ /) { print ERRORS $line . "\n"; } else { my $results = `$ct describe $line | $grep $label`; if ($results =~ m/$label/) { print TARBALL_INPUT_FILE $line . "\n"; } else { print UNASSOCIATED $line . "\n"; } } } print "\n"; close (PIPE); close (LOG); close (ERRORS); close (TARBALL_INPUT_FILE); close (UNASSOCIATED); ********************************************** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>