Perl command error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl command error
# 1  
Old 11-20-2014
Perl command error

In the attached file I get this error. Thank you Smilie.

Code:
 C:\cygwin\home\cmccabe\windows_annovar.sh: line 117: perl: command not found

# 2  
Old 11-20-2014
You can't use a shebang such as "#!/bin/bash" in Windows. It just doesn't work that way. you need to look at how to write perl code for windows. You need to run perl from a .bat file that calls the perl executable directly and passes in the perl script as an argument to the perl executable.
# 3  
Old 11-21-2014
Code:
String found where operator expected at C:\cygwin\home\cmccabe\windows_annovar.sh line 16, near "case "$menu_choice""
        (Do you need to predeclare case?)
Number found where operator expected at C:\cygwin\home\cmccabe\windows_annovar.sh line 17, near "1"
        (Missing semicolon on previous line?)
Bareword found where operator expected at C:\cygwin\home\cmccabe\windows_annovar.sh line 17, near ") match"
        (Missing operator before match?)
Bareword found where operator expected at C:\cygwin\home\cmccabe\windows_annovar.sh line 18, near ") sanger"
        (Missing operator before sanger?)
Bareword found where operator expected at C:\cygwin\home\cmccabe\windows_annovar.sh line 19, near ") batch"
        (Missing operator before batch?)
Bareword found where operator expected at C:\cygwin\home\cmccabe\windows_annovar.sh line 20, near ") individual"
        (Missing operator before individual?)
Bareword found where operator expected at C:\cygwin\home\cmccabe\windows_annovar.sh line 21, near ") supplemental"
        (Missing operator before supplemental?)
syntax error at C:\cygwin\home\cmccabe\windows_annovar.sh line 3, near ") {"
Missing comma after first argument to read function at C:\cygwin\home\cmccabe\windows_annovar.sh line 16, near "case "$menu_choice""
syntax error at C:\cygwin\home\cmccabe\windows_annovar.sh line 16, near "case "$menu_choice""
syntax error at C:\cygwin\home\cmccabe\windows_annovar.sh line 18, near "2) "
syntax error at C:\cygwin\home\cmccabe\windows_annovar.sh line 19, near "3) "
syntax error at C:\cygwin\home\cmccabe\windows_annovar.sh line 20, near "4) "
syntax error at C:\cygwin\home\cmccabe\windows_annovar.sh line 21, near "5) "
syntax error at C:\cygwin\home\cmccabe\windows_annovar.sh line 22, near "6) "
syntax error at C:\cygwin\home\cmccabe\windows_annovar.sh line 23, near "*) printf"
syntax error at C:\cygwin\home\cmccabe\windows_annovar.sh line 25, near "}"
C:\cygwin\home\cmccabe\windows_annovar.sh has too many errors.

I am not sure where to go. Thank you Smilie.
# 4  
Old 11-21-2014
You have to run it with perl commandname. Windows doesn't know or care what the #! line is.

Since it is not a bourne shell file, you shouldn't name it sh either. .pl would be more traditional for perl scripts.
# 5  
Old 11-21-2014
I am trying to use VB in excel to call and execute the .sh file:

VB
Code:
 
Private Sub CommandButton1_Click()
    Dim cmd As String
    Dim ret As Double
    Dim WshShell As Object
    Dim plink_object As Object
    ' Run Linux Commands
    Set WshShell = CreateObject("WScript.Shell")
    On Error Resume Next
    Set plink_object = WshShell.Run("C:\cygwin\bin\mintty.exe C:\cygwin\home\cmccabe\windows_annovar.sh 66 ""50602_15:56:31_15:56:11_15:56:21;50602_15:57:07_15:56:47_15:56:57""", 1)
    On Error GoTo 0
End Sub

As of know it errors on the perl commands:
Code:
 C:\cygwin\home\cmccabe\windows_annovar.sh: line 117: perl: command not found

As a bash it runs fine as is but windows doesent seem to like it. I am not familiar enough with windows and perl.... linux seems much nicier. Thanks Smilie.
# 6  
Old 11-21-2014
Quote:
Originally Posted by cmccabe
I am trying to use VB in excel to call and execute the .sh file
For the third time -- it is not an sh file. You should be running it in perl because it is perl and not shell.

Running it in shell instead of perl will cause the problems you have seen, because the shell does not understand the perl code when running it in shell instead of perl.

The way to run it is to use perl instead of shell, so it runs using perl, which understands perl programs.

... mintty.exe perl script.sh
# 7  
Old 11-21-2014
VB
Code:
 Private Sub CommandButton1_Click()
    Dim cmd As String
    Dim ret As Double
    Dim WshShell As Object
    Dim plink_object As Object
    ' Run Linux Commands
    Set WshShell = CreateObject("WScript.Shell")
    On Error Resume Next
    Set plink_object = WshShell.Run("C:\cygwin\bin\mintty.exe C:\cygwin\home\cmccabe\windows_annovar.pl 66 ""50602_15:56:31_15:56:11_15:56:21;50602_15:57:07_15:56:47_15:56:57""", 1)
    On Error GoTo 0
End Sub

Code:
 
C:\cygwin\home\cmccabe\windows_annovar.pl: line 36: perl: command not found 

perl code:
Code:
 match() {
    printf "\n\n"
    printf "DEBUG INFO: VALUE OF \$id: %s, VALUE OF \$panel: %s\n" $id $panel
    printf "What is the id of the patient to be matched  : "; read id
    printf "What panel: "; read panel
    [ -z "$id" ] && printf "\n No ID supplied. Leaving match function." && sleep 2 && menu
    [ "$id" = "end" ] && printf "\n Leaving match function." && sleep 2 && menu
    cd 'C:\Users\cmccabe\Desktop\annovar'
    OMR=Output_Mutation_Report
               perl -aF/\\t/ -lne 'BEGIN{%m=map{chomp;s/\cM|\cJ//g;$p=join("\t",(split/\t/)[4,5]);($p,$_)} <>;$m{"#CHROM\tINFO"}=$m{"Chr\tSegment Position"}};/SEGPOS=(\d+)/ || /\t(INFO)\t/ or next;$p=$F[0]."\t".$1;exists $m{$p} and print join("\t",$_,$m{$p})' ${id}_${panel}_${OMR}.txt < ${id}_${panel}_${OMR}_Filtered.vcf > ${id}_matched.vcf
    convert

from the perl code I removed the $( ). Thank you Smilie.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Perl error : perl: warning: Setting locale failed.

This's my problem perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_ALL = "en_US.UTF-8", LC__FASTMSG = "true", LC_MESSAGES = "", LC_CTYPE = "en_US.UTF-8", LC_TYPE = "en_US.UTF-8", LANG = "EN_US"... (1 Reply)
Discussion started by: bobochacha29
1 Replies

2. Shell Programming and Scripting

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 :). ... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. 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

4. Shell Programming and Scripting

Perl & Sed command -- Out of Memory Error

Experts, We used to receive our source files with '~^' as row delimiter. This file contains 2500K records and two of the columns having value in HTML formats within the file. While running the below commands against the file, we are encountering out of memory, could you please help to... (3 Replies)
Discussion started by: srivijay81
3 Replies

5. Shell Programming and Scripting

Perl command error...

Good morning! Imtrying to run: #!/usr/bin/perl perl -nle 'print if /\var\/log/' /etc/syslog.confBut I keep getting error: Do you need to predeclare -nle.Im trying to create a script that read the contents of /etc/syslog.conf and print out every line that contains /var/log. (1 Reply)
Discussion started by: bigben1220
1 Replies

6. Shell Programming and Scripting

Convert Sed command to perl command

Hello, Can any perl experts help me convert my sed string to perl. I am unsuccessful with this. I have to remove this string from html files OAS_AD('Top'); I have come up with this. However the requirement is in perl. for find in $(find . -type f -name "file1.html") ; do cat $find |... (2 Replies)
Discussion started by: abacus
2 Replies

7. Shell Programming and Scripting

combine two perl lines into a single perl command

Hi Everyone, i have a string 00:44:40 so: $tmp=~ s/://gi; $tmp=~s/({2})({2})({2})/$1*3600+$2*60+$3/e; the output is 2680. Any way to combine this two lines into a single line? Thanks (4 Replies)
Discussion started by: jimmy_y
4 Replies

8. Shell Programming and Scripting

Error executing shell command from a perl script

Hi Gurus, I've a find command that gets the list of files from a source directory where the extension is not html, xml, jsp, shtml or htaccess. The below find command runs fine from the command prompt or in a shell script. I need to eventually run it in a PERL script and am getting the... (5 Replies)
Discussion started by: voorkey
5 Replies

9. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

10. Shell Programming and Scripting

Perl Script Error with find command

Guys, I need to find all the files ending with either dmp or dmp.Z. This command is giving me error. @files =`find $path \(-name "*.dmp" -o -name "*.dmp.Z"\) -mtime +30`; sh: 0403-057 Syntax error at line 1 : `(' is not expected. Thanks in advance (4 Replies)
Discussion started by: MKNENI
4 Replies
Login or Register to Ask a Question