Hi all
I have some executable files (in other programming language) and I am trying to build a wrapper script with perl. I have partially succeeded in the task. But I need to run three system commands(in other words three different executable files) and I could run the first and the second without anyproble. The second and the third executables are with ina foreach loop. So, it executes the first system cmd (with in the foreach loop) and exits. If I commented the first system cmd after exiting the second one runs with out any problem.


Is that as simple as the file dependencies of the second cmd from the first? Or is there a logic problem with the way I have build the script?
I hav attached the code for your opinion
#!/software/bin/perl use strict; use warnings ; use File::Copy; use File::Basename; use File::Listing; my $rootdir = $ARGV[0]; my $celfile = $ARGV[1]; my $cfile = fileparse($celfile); my $sample = $ARGV[2]; my $cdfdir = $rootdir . "/cdf"; my $celdir = $rootdir . "/cel"; my $outdir = $rootdir . "/outdir"; mkdir($cdfdir, 0755) || print "Couldn't make dir $!\n"; mkdir($celdir,0755) || print "Couldn't make Celdir $!\n"; my $cdffile = "/nfs/team78pc/Individuals_Folders/cdg/TRANSFER/viewer/p +icnicGUI_unix/src/GenomeWideSNP_6.fromDB.cdf"; copy("$cdffile", "$cdfdir/GenomeWideSNP_6.fromDB.cdf") or die "copy fa +iled $!\n"; copy("$celfile", "$celdir/$cfile") or die "copy of celfile failed $!\n +"; mkdir ($outdir,0755) || print "Couldn't create outputdir : $!\n"; chdir($rootdir) || die "Can't change directory $!\n"; my $cmd1 = "java -Xmx2G -jar $rootdir/celConverter/CelFileConverter.ja +r -m $rootdir/celConverter/Snp6FeatureMappings.csv -c $rootdir/cdf/Ge +nomeWideSNP_6.fromDB.cdf -s $celdir/ -t $rootdir/outdir/raw"; system($cmd1); my $dir = "$rootdir/outdir/output2/$sample" . "_feature.TXT"; opendir(DIR, "$rootdir/outdir/raw") || "Cannot open the directory $!\n +"; opendir(ODIR,"$dir") || "Cannot open output2directory $! \n"; foreach my $file (readdir(DIR)){ if($file =~ /feature_intensity$/){ #my $cmd = "sh run_preprocessing.sh $rootdir/Matlab_Compilet_Runtime +/v710/ $file $rootdir/info/ $rootdir/outdir/raw/ $rootdir/outdir/outp +ut/ $rootdir/outdir/ PRIMARY 0.5"; #warn "Running $cmd... \n"; #system($cmd); #outputs ploidy_3456_feature.TXT.csv foreach my $file2(readdir(ODIR)){ if($file2 =~ /^ploidy\_$sample\_feature\.TXT\.csv$/){ open(FILE, "<$dir/$file2") || "Cannot open the file $file2 $!\n"; +#output from the previous system cmd. while(<FILE>){ chomp; my ($in_pi,$in_ploidy,$in_alpha) = split(/,/); my $cmd2 = "sh run_HMM.sh $rootdir/Matlab_Compilet_Runtime/v710/ +$file $rootdir/info/ $rootdir/outdir/output/ $rootdir/outdir/ 10 $in_ +pi $in_ploidy $in_alpha"; warn "Running $cmd2\n"; system($cmd2); } close FILE; } } } }
Thanks a ton

In reply to Running executables with perl using system command by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.