Perl error in batch command but works one at a time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl error in batch command but works one at a time
# 1  
Old 02-02-2017
Perl error in batch command but works one at a time

In the below perl executes if one file is processed perfect. However, when multiple files are processed in batch which is preferred I get the below error that I can not seem to fix it as the '' necessary for the command to execute, but seem to only work for one -arg option. Thank you Smilie.

command to process one file at a time
Code:
perl -ne 'chomp; system ("perl table_annovar.pl -vcfinput file.vcf humandb/ -buildver hg19 -arg '-hgvs',,,,, -remove -protocol IDP.refGene,avsnp147,popfreq_all_20150413,spidex,dbnsfp33a,clinvar_20161128 -operation g,f,f,f,f,f -otherinfo -nastring .")' < target.txt

Using a batch command I get:

Batch command to process all files in target.txt
Code:
perl -ne 'chomp; system ("perl table_annovar.pl -vcfinput $_ humandb/ -buildver hg19 -arg '-splicing_threshold 50 -hgvs',,,,, -remove -protocol IDP.refGene,avsnp147,popfreq_all_20150413,spidex,dbnsfp33a,clinvar_20161128 -operation g,f,f,f,f,f -otherinfo -nastring .")' < target.txt
Can't find string terminator '"' anywhere before EOF at -e line 1.

Code:
perl -ne 'chomp; system ("perl table_annovar.pl -vcfinput $_ humandb/ -buildver hg19 -arg -splicing_threshold 50 -hgvs,,,,, -remove -protocol IDP.refGene,avsnp147,popfreq_all_20150413,spidex,dbnsfp33a,clinvar_20161128 -operation g,f,f,f,f,f -otherinfo -nastring .")' < target.txt
Unknown option: hgvs,,,,,


Last edited by cmccabe; 02-02-2017 at 09:52 AM.. Reason: fixed format, added details
# 2  
Old 02-02-2017
That is not Perl. The membrane-thin wrapper of Perl serves literally no purpose. That is nothing but shell code. If you write the loop inside shell you'll save so much trouble and CPU time.

I too made this error when first learning to program in Perl and shell. Learn a little more shell and it will make more sense.

You can also split across multiple lines for readability by putting backslash-newline wherever you need to split it.
Code:
while read LINE
do
        echo perl table_annovar.pl -vcfinput "$LINE" humandb/ -buildver hg19 -arg '-hgvs',,,,, -remove -protocol \
                IDP.refGene,avsnp147,popfreq_all_20150413,spidex,dbnsfp33a,clinvar_20161128 \
                -operation g,f,f,f,f,f -otherinfo -nastring .
done < target.txt

Remove the echo once you've tested and made sure it does what you want.

Last edited by Corona688; 02-02-2017 at 11:32 AM..
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 02-02-2017
Thank you very much Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script in bash that works only some of the time

I ran this script yesterday (in the background) /usr/bin/nohup myfilelocation/myscriptname.sh & the script worked perfectly. i ran it today (also in the background) and just sat there. So i killed it and ran it normally and it worked perfectly. Anyone suggest why it just sat there and... (8 Replies)
Discussion started by: twinion
8 Replies

2. Shell Programming and Scripting

perl: Command works in terminal, but not in shell script

Hi, the following command works in the terminal no problem. samtools view -h rawlib.bam | perl -ne '{ @line = split( /\s+/ ); $match = 0; while( $line =~ /(\d+)M/g ) { $match = $match + $1 } if( $match >= 80 || $_ =~ /^\@/ ) { print $_ } }' | java -Xmx12G -jar... (8 Replies)
Discussion started by: jdilts
8 Replies

3. Shell Programming and Scripting

Xentop Batch Time Display Help

I would like to be able to display the local time (or anytime for that matter) when I run Xentop in batch mode. Is that possible? (In other words, when I look back at the data, I want to be able to tell what time that the output was displayed). (2 Replies)
Discussion started by: Coyote2012
2 Replies

4. Shell Programming and Scripting

Ftp script hangs for first time,but works every second time

Hi I have an ftp script which works fine when i execute through a test scheduler(UC4), but when i run it through the prod scheduler(UC4), it hungs indefinetely, when we cancel the job and re-run it it works perfectly fine. here is the code,, any idea why this is happening ???? ... (1 Reply)
Discussion started by: selvankj
1 Replies

5. Windows & DOS: Issues & Discussions

Command works on CMD line but not in batch?

Hi All, This command works when I type it on but when I run the batch file it doesn't..any ideas why? attrib.exe * | find /c /v "" >filecount.txt (1 Reply)
Discussion started by: Grueben
1 Replies

6. Shell Programming and Scripting

Syntax error piping to bc on command line - works when assigned to var

I have a script which outputs some timing data a line at a time. There are approx. 10 lines echoed, each line looks something like this: 0.741 http://checkip.dyndns.org 94.170.119.226Since I needed to add all the values in the first column, I piped the output to grep, matching and printing the... (7 Replies)
Discussion started by: gencon
7 Replies

7. Shell Programming and Scripting

perl/unix: script in command line works but not in perl

so in unix this command works works and shows me a list of directories find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt but when i try running a perl script to run this command my $query = 'find . -name \*.xls -exec dirname {} \; | sort -u | > list.txt';... (2 Replies)
Discussion started by: kpddong
2 Replies

8. HP-UX

Strange- RCP command works every other time

This just started happening. I use the rcp command to copy a file from one server to another. Now when I use the command, every other time I execute the exact same command I get the error: remshd: login correct Example: 1. rcp testfile server2:/db/tmp (Work ok, verified file... (6 Replies)
Discussion started by: jrowland
6 Replies

9. Shell Programming and Scripting

time stamp perl script error out of range 1..31

Hi, while running the perl script i am getting this error message , Day '' out of range 1..31 at rsty.sh line 44 what do iam missing in the script, any suggestion #!/usr/bin/perl use Time::Local; my $wday = $ARGV; my $month = $ARGV; # convert the month shortname into 0-11 number if... (4 Replies)
Discussion started by: saha
4 Replies
Login or Register to Ask a Question