LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-24-2010, 06:20 AM   #1
rohit0825
LQ Newbie
 
Registered: Jan 2010
Posts: 23

Rep: Reputation: 15
Question Syntax Error -- related Perl


I have an executable file named macstat, macstat is attached with this message. i have added .txt extension to it as the file without extension was not able to attach.

Whenever i run this file on my linux pc running fedora core 4, i get the following error in terminal:


Code:
[root@ethertester ~]# macstat
Code:
/asic/common/bin/macstat: 
line 16: use: command not found
/asic/common/bin/macstat: line 17: use: command not found
/asic/common/bin/macstat: line 19: my: command not found
/asic/common/bin/macstat: line 20: my: command not found
/asic/common/bin/macstat: line 21: my: command not found
/asic/common/bin/macstat: line 23: syntax error near unexpected token `}'
/asic/common/bin/macstat: line 23: `sub usage {die "Usage: macstat save|calc ethx\n";}'



The result of the command:

Code:
[root@ethertester ~]# macstat save eth0


should be:

Code:
macstat version 1.3


I think macstat is a perl file and i don't know anything about perl. A file named perl, csh and tcsh is located in /usr/local/bin.

Please help me out asap.
Thank you in anticipation.
Attached Files
File Type: txt macstat.txt (2.7 KB, 14 views)

Last edited by rohit0825; 01-24-2010 at 01:31 PM.
 
Old 01-24-2010, 07:05 AM   #2
zordrak
Member
 
Registered: Feb 2008
Distribution: Slackware
Posts: 595

Rep: Reputation: 115Reputation: 115
Try:
Code:
$ /usr/local/bin/perl -w /asic/common/bin/macstat
 
Old 01-24-2010, 07:18 AM   #3
rohit0825
LQ Newbie
 
Registered: Jan 2010
Posts: 23

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by zordrak View Post
Try:
Code:
$ /usr/local/bin/perl -w /asic/common/bin/macstat
Thanks for your reply
i got the following error after i run the above command.

bash: /usr/local/bin/perl : cannot execute binary file
 
Old 01-24-2010, 07:41 AM   #4
rohit0825
LQ Newbie
 
Registered: Jan 2010
Posts: 23

Original Poster
Rep: Reputation: 15
Please Somebody HELP
 
Old 01-24-2010, 08:07 AM   #5
ricstirato
Member
 
Registered: Jan 2004
Location: Gießen, Germany
Distribution: Xubuntu 12.04, Mythbuntu, Ubuntu Server 12.04
Posts: 174

Rep: Reputation: 24
The macstat script's shebang line (first line, #!/usr/local....) expects perl to be /usr/local/bin/perl

Find out where your perl binary is:

Code:
$ which perl
Probably this will report "/usr/bin/perl"

Change the shebang line in macstat accordingly and try

Code:
$ ./macstat
 
Old 01-24-2010, 08:27 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153
How about editing line 1 in " macstat "
to /usr/bin/perl

.. which is the default location for the binary ' perl '
in Fedora.

Runs OK : perl macstat
.. and replies : Usage: macstat save|calc ethx
.....

Last edited by knudfl; 01-24-2010 at 08:30 AM.
 
Old 01-24-2010, 08:31 AM   #7
rohit0825
LQ Newbie
 
Registered: Jan 2010
Posts: 23

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ricstirato View Post
The macstat script's shebang line (first line, #!/usr/local....) expects perl to be /usr/local/bin/perl

Find out where your perl binary is:

Code:
$ which perl
Probably this will report "/usr/bin/perl"

Change the shebang line in macstat accordingly and try

Code:
$ ./macstat
Actually i have pasted perl file from another system to /usr/local/bin directory.
and
Code:
which perl
also return
Code:
/usr/local/bin
 
Old 01-24-2010, 08:46 AM   #8
rohit0825
LQ Newbie
 
Registered: Jan 2010
Posts: 23

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by knudfl View Post
How about editing line 1 in " macstat "
to /usr/bin/perl

.. which is the default location for the binary ' perl '
in Fedora.

Runs OK : perl macstat
.. and replies : Usage: macstat save|calc ethx
.....
Thanks...
I have pasted perl file from another pc to /usr/local/bin folder.
i don't know whether perl already existed in /usr/bin.

please guide.
 
Old 01-24-2010, 09:58 AM   #9
tlau
LQ Newbie
 
Registered: Jan 2010
Posts: 1

Rep: Reputation: 0
Maybe you can replace the first line of macstat with
#!/bin/env perl
Then it will find perl by itself.

By the way, if you just pasted a perl from another PC, it may cause problems, due to the libraries compatible issue.
 
Old 01-25-2010, 02:50 AM   #10
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153
Quote:
I have pasted perl file from another pc to /usr/local/bin folder
Asking for trouble ? Better delete it again.

And edit your program to point to /usr/bin/
.. where the default perl executable is located
( in all Linux, Fedora included.)
.....
 
Old 01-25-2010, 04:49 AM   #11
zordrak
Member
 
Registered: Feb 2008
Distribution: Slackware
Posts: 595

Rep: Reputation: 115Reputation: 115
Quote:
Originally Posted by rohit0825 View Post
Thanks for your reply
i got the following error after i run the above command.

bash: /usr/local/bin/perl : cannot execute binary file
Provide output of:

Code:
$ file /usr/local/bin/perl
$ ls -la /usr/local/bin/perl
 
Old 01-25-2010, 08:27 AM   #12
rohit0825
LQ Newbie
 
Registered: Jan 2010
Posts: 23

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by knudfl View Post
Asking for trouble ? Better delete it again.

And edit your program to point to /usr/bin/
.. where the default perl executable is located
( in all Linux, Fedora included.)
.....
Thanks....
Problem Solved by changing first line of macstat.
/usr/bin/perl is correct.
 
Old 01-25-2010, 08:40 AM   #13
rohit0825
LQ Newbie
 
Registered: Jan 2010
Posts: 23

Original Poster
Rep: Reputation: 15
Thanks Everybody for your support

Last edited by rohit0825; 01-25-2010 at 09:43 AM.
 
  


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
Is this syntax related to c++ templates ? TheIndependentAquarius Programming 2 01-19-2010 11:46 PM
perl script syntax error matt007 Programming 2 09-17-2009 12:00 PM
perl dbi:mysql shows error syntax error dbi:mysql ?? haxpak Linux - Server 4 02-27-2009 12:09 AM
syntax error near unexpected token in bash using perl kambrish Programming 21 07-03-2007 01:42 PM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 07:09 PM


All times are GMT -5. The time now is 03:55 PM.

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