LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-30-2015, 06:04 AM   #1
Zahra_SA
LQ Newbie
 
Registered: Mar 2015
Posts: 6

Rep: Reputation: Disabled
Question sh: -c: line 1: syntax error near unexpected token `('


Hi,
I am working with a software that is based on Perl scripting and I have encountered with a bash scripting error. So as I am not familiar with bash scripting well, I don't know how I can solve.
sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: ` 32(andRlooks_unw'

It should be mentioned that my $SHELL is /bin/bash. Could you please guide me what '-c' is? where is it? if I change the shebang (the #!/bin/sh part) to #!/bin/bash, the problem will be solved?

Regards,
Zahra
 
Old 03-30-2015, 06:12 AM   #2
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Welcome to LQ!

Have a nice time.

/bins/sh -c 'some shell script' is used to pass/execute valid shell expressions to shell.

Can you give what you tried to execute. You can read more about shell in man page of bash.
 
1 members found this post helpful.
Old 03-30-2015, 06:54 AM   #3
Zahra_SA
LQ Newbie
 
Registered: Mar 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks a lot for your prompt reply!
apologies if this problem is so trivial.
If I understood correctly the -c is a script, may I know how can I open that?
this is the full text of error:
sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: ` 32(andRlooks_unw'
+process_2pass.pl look.pl failed in process_2pass.pl


I am trying to execute process_2pass.pl code that look.pl code is calling in it:
(part of process_2pass.pl)
chdir $IntDir;
`$INT_SCR/look.pl $im12.cor \\
$Rlooks_unw`;
Status "look.pl";

`$INT_SCR/look.pl $im12.amp \\
$Rlooks_unw`;
Status "look.pl";

Regards,
Zahra
 
Old 03-30-2015, 07:09 AM   #4
Zahra_SA
LQ Newbie
 
Registered: Mar 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thanks for your quick reply!

As I understood correctly, the -c is the script based on sh shell. How can I open this script?

The full text of the error is here:sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: ` 32(andRlooks_unw'
+process_2pass.pl look.pl failed in process_2pass.pl

I am trying to execute process_2pass.pl based on Perl scripting, that is called in it look.pl, but I think this line
' 32(andRlooks_unw' is related to a bash script( -c), but I don't know where it is?

Regards,
Zahra
 
Old 03-30-2015, 07:41 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,110
Blog Entries: 10

Rep: Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525
It doesn't appear to be a bash script, but instead a Perl script. Therefore you need to run it using perl.

At least post the first few lines of the script within [code][/code] tags.

If the first line says something like:
Code:
#/bin/sh
or:
Code:
#/bin/bash
then it is a BASH script, otherwise it may be a Perl script since this is the language you identified.
 
Old 03-30-2015, 07:48 AM   #6
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Example using -c:

Code:
/bin/sh -c 'ls'
Lists files

Show your perl script.
 
Old 03-30-2015, 07:55 AM   #7
Zahra_SA
LQ Newbie
 
Registered: Mar 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
This is the whole text of look.pl:
#!/usr/bin/perl
###look.pl

$] >= 5.004 or die "Perl version must be >= 5.004 (Currently $]).\n";

use Env qw(INT_BIN INT_SCR);
use lib "$INT_SCR"; #### Location of Generic.pm
use Generic;

###Usage info/check

sub Usage{

`$INT_SCR/pod2man.pl $INT_SCR/look.pl`;
exit 1;
}
@ARGV > 0 or Usage();
@args = @ARGV;

### Get arguments and check if default # looks are needed
$infile = shift;
$Rlooks = shift;
$Alooks = shift;

$Rlooks or $Rlooks = 4;
$Alooks or $Alooks = $Rlooks;

$infile =~ /\.(slc|int|cor|unw|amp|hgt|msk|dem|byt)$/ or Usage();
$prefix = $`;
$suffix = $1;

### Extract file suffix, prefix and total number of looks
if ($infile =~ m!_(\d+)rlks!){
$totallooks = $Rlooks*$1;
$outfile = "$`"."_$totallooks"."rlks$'";
}
else {
$totallooks = $Rlooks;
$outfile = $prefix."_".$Rlooks."rlks.$suffix";
}
if ($Rlooks == 1 and $Alooks == 1){
exit 0;
}

#################
Message "Checking I/O";
#################
@Infiles = ($infile, "$infile.rsc");
@Outfiles = ($outfile,"$outfile.rsc");
&IOcheck(\@Infiles, \@Outfiles);
Log ("look.pl", @args);

### Obtain old .rscfile data
$width = Use_rsc "$infile read WIDTH";
$length = Use_rsc "$infile read FILE_LENGTH";
$xmin = Use_rsc "$infile read XMIN";
$xmax = Use_rsc "$infile read XMAX";
$ymin = Use_rsc "$infile read YMIN";
$ymax = Use_rsc "$infile read YMAX";

if ($suffix =~ /(dem|dte|dtm)/){
$oldRlooks = Use_rsc "$infile read RLOOKS";
if ($oldRlooks) {
$oldAlooks = Use_rsc "$infile read ALOOKS";
}
else{
$oldRlooks = 1;
$oldAlooks = 1;
}
}
else{
$start = Use_rsc "$infile read FILE_START";
$delta_line_utc = Use_rsc "$infile read DELTA_LINE_UTC";
$oldRlooks = Use_rsc "$infile read RLOOKS";
$oldAlooks = Use_rsc "$infile read ALOOKS";
$oldRlooks == 0 and die "Need to fix $infile.rsc for looks\n";
$range_pixel_size = Use_rsc "$infile read RANGE_PIXEL_SIZE";
$azimuth_pixel_size = Use_rsc "$infile read AZIMUTH_PIXEL_SIZE";

$range_pixel_size = $range_pixel_size*$Rlooks;
$azimuth_pixel_size = $azimuth_pixel_size*$Alooks;
$delta_line_utc = $delta_line_utc*$Alooks;
Use_rsc "$outfile write DELTA_LINE_UTC $delta_line_utc";
}

unless ($range_pixel_size){
$xstep = Use_rsc "$infile read X_STEP";
$ystep = Use_rsc "$infile read Y_STEP";
}

### Write new .rscfile
Use_rsc "$outfile merge $infile";

$newwidth = int($width/$Rlooks);
$newlength = int($length/$Alooks);
$xmin = int($xmin/$Rlooks);
$xmax = int($xmax/$Rlooks);
$ymin = int($ymin/$Alooks);
$ymax = int($ymax/$Alooks);
$xstep = $xstep*$Rlooks;
$ystep = $ystep*$Alooks;
$newRlooks = $oldRlooks*$Rlooks;
$newAlooks = $oldAlooks*$Alooks;

Use_rsc "$outfile write WIDTH $newwidth";
Use_rsc "$outfile write FILE_LENGTH $newlength";
Use_rsc "$outfile write FILE_START $start";
Use_rsc "$outfile write XMIN $xmin";
Use_rsc "$outfile write XMAX $xmax";
Use_rsc "$outfile write YMIN $ymin";
Use_rsc "$outfile write YMAX $ymax";
Use_rsc "$outfile write DELTA_LINE_UTC $delta_line_utc";
Use_rsc "$outfile write RLOOKS $newRlooks";
Use_rsc "$outfile write ALOOKS $newAlooks";

if ($range_pixel_size) {
Use_rsc "$outfile write RANGE_PIXEL_SIZE $range_pixel_size";
Use_rsc "$outfile write AZIMUTH_PIXEL_SIZE $azimuth_pixel_size";
}
else {
Use_rsc "$outfile write X_STEP $xstep";
Use_rsc "$outfile write Y_STEP $ystep";
}

################
Message "Wrote new rscfile";
################
if ($suffix eq "hgt"){
$azimuth_pixel_grnd = Use_rsc "$infile read AZIMUTH_PIXEL_GROUND";
$azimuth_pixel_grnd = $azimuth_pixel_grnd*$Rlooks;
Use_rsc "$outfile write AZIMUTH_PIXEL_GROUND $azimuth_pixel_grnd";
Doc_rsc(
RSC_Tip => '',
RSC_Doc => q[
Uninitialized keyword.
],
RSC_Derivation => q[
Value is 0 because look.pl is reading keyword
that has not been written prior to look.pl being called.

Only occurs when file with 'hgt' $suffix given to look.pl
],
RSC_Comment => q[
Value does not appear to be used anywhere.
],
RSC_Type => Real,
RSC_Unit => 'SI:meter',
);


}

################
Message "Using lookdown routine";
### Use one of the lookdown programs, depending on the suffix

if ($suffix eq "amp"){
open LOOK, "|$INT_BIN/rilooks";
print LOOK "$infile
$outfile
$width $length
$Rlooks $Alooks\n" or die "Lookdown failed: $!\n";
close(LOOK);
}
elsif ($suffix =~ /int/){
open LOOK, "|$INT_BIN/cpxlooks";
print LOOK "$infile
$outfile
$width $length
$Rlooks $Alooks
0 0\n" or die "Lookdown failed: $!\n";
close(LOOK);
}
elsif ($suffix =~/slc/){
open LOOK, "|$INT_BIN/powlooks";
print LOOK "$infile
$outfile
$width $length
$Rlooks $Alooks
0 0\n" or die "Lookdown failed: $!\n";
close(LOOK);
}
elsif ($suffix =~ /(cor|hgt|unw|msk)/){
`$INT_BIN/nbymhgt $infile $outfile $width $Rlooks $Alooks`;
Status "nbymhgt";
}
elsif ($suffix =~ /(dem|dte|dtm)/){
`$INT_BIN/nbymdem $infile \\
$outfile \\
$width \\
$Rlooks \\
$Alooks`;
Status "nbymdem";
}
elsif ($suffix =~ /(byt)/){
`$INT_BIN/nybmbyt $infile \\
$outfile \\
$width \\
$length \\
$Rlooks \\
$Alooks`;
Status "nbymbyt";
}

`rm -f core`;
`rm -f keywords`;
exit 0;
=pod

=head1 USAGE

B<look.pl> I<imagefile [looks in range] [looks in azimuth]>

default number of looks in range = 4

default number of looks in azimuth = looks in range

Recognizes: *.slc
*.int
*.cor
*.unw
*.amp
*.hgt
*.msk
*.dem
*.dte
*.dtm
*.byt

=head1 FUNCTION

Takes specified number of looks down on imagefile

=head1 ROUTINES CALLED

rilooks

nbymhgt

cpxlooks

powlooks

=head1 CALLED BY

process.pl

make_sim.pl

=head1 FILES USED

I<imagefile>

I<imagefile>.rsc

=head1 FILES CREATED

I<imagefile>_I<looks>rlks

I<imagefile>_I<looks>rlks.rsc

=head1 HISTORY

Shell Script : Francois ROGEZ 96/98

Perl Script : Rowena LOHMAN 04/18/98

=head1 LAST UPDATE

Rowena Lohman, Oct 13, 1999

=cut


Regards,
 
Old 03-30-2015, 08:09 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,110
Blog Entries: 10

Rep: Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525
And have you used "perl" to run that script?
Code:
perl look.pl
 
Old 03-30-2015, 08:20 AM   #9
Zahra_SA
LQ Newbie
 
Registered: Mar 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
All Perl scripts are in INT_SCR directory, and I used 'export INT_SCR="/Users/zas/Documents/zahra/ROI-PAC/ROI_PAC_3_1beta/ROI_PAC/INT_SCR"' and after that I use 'source' command to the text file containing export INT_SCR=...
 
Old 03-30-2015, 08:27 AM   #10
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,110
Blog Entries: 10

Rep: Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525
Quote:
Originally Posted by Zahra_SA View Post
All Perl scripts are in INT_SCR directory, and I used 'export INT_SCR="/Users/zas/Documents/zahra/ROI-PAC/ROI_PAC_3_1beta/ROI_PAC/INT_SCR"' and after that I use 'source' command to the text file containing export INT_SCR=...
The source command is just the same as "./executable-file-name"

You're trying to execute the file.

I don't see how you're getting that error in the first place, the assumption was that you were trying to execute a particular Perl script, which I still believe to be the case.

Probably the best thing to do is to capture the terminal data and post that, editing out any specifics like username or whatever you consider to be private.

Either case, it's hard to discern what you're doing.

Using source to run a file which contains an export line is fine. There's either a syntax error in that file, or something else wrong.

To run a Perl script, you issue the "perl" command which is typically located at /usr/bin/perl, but you can issue "which perl" to find where it's located at. That should be in your path anyways so you probably can just type "perl script-file-name" as I showed before.
 
Old 03-30-2015, 09:04 AM   #11
Zahra_SA
LQ Newbie
 
Registered: Mar 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
let me to explain clearly,
I am running the perl script of a software (ROI-pac), the name of this script is process_2pass.pl,
as all perl scripts of this software (same as process_2pass.pl) are in the INT_SCR directory, I wrote the'export INT_SCR="/Users/zas/Documents/zahra/ROI-PAC/ROI_PAC_3_1beta/ROI_PAC/INT_SCR"' in the file named SAR_CONFIG and first of all:
msslm1:ROI_PAC zas$ source SAR_CONFIG
after that:
msslm1:TEST_DIR zas$ process_2pass.pl
during the running this code, I have encountered with this error:
sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: ` 32(andRlooks_unw'

look.pl is another perl script that is called in the process_2pass.pl.
I need to know where is -c? how can I open and change that? Veera siad is in /bin/sh, but there isn't sh directory in /bin:
msslm1:// zas$ cd bin/
msslm1:bin zas$ ls
[ df launchctl pwd tcsh
bash domainname link rcp test
cat echo ln rm unlink
chmod ed ls rmdir wait4path
cp expr mkdir sh zsh
csh hostname mv sleep
date kill pax stty
dd ksh ps sync
msslm1:bin zas$ cd sh
-bash: cd: sh: Not a directory
msslm1:bin zas$

Please let me know if you need more information
Regards
 
Old 03-30-2015, 09:13 AM   #12
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,110
Blog Entries: 10

Rep: Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525Reputation: 1525
Quote:
Originally Posted by Zahra_SA View Post
msslm1:TEST_DIR zas$ process_2pass.pl
Right there is your problem:
Code:
perl process_2pass.pl
Whether or not look.pl was the original file, I think it was pretty clear that to RUN a Perl script you've been told a few times that you need to use the perl command which is typically located at /usr/bin/perl.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax error near unexpected token `fi' Warmduvet Programming 21 10-08-2013 11:28 AM
./menu.txt: line 1: syntax error near unexpected token 'new line' jhouston2010 Linux - Newbie 10 03-12-2013 02:56 PM
syntax error near unexpected token `fi' thomas2004ch Programming 11 08-04-2011 08:53 AM
[SOLVED] Repeatedly getting command substitution: line 3: syntax error near unexpected token dontob Linux - General 8 08-31-2010 09:26 AM
./script.sh: line 2: syntax error near unexpected token `(' n00balert Programming 3 03-11-2010 05:22 PM


All times are GMT -5. The time now is 11:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration