The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to run cmds after changing to a new env (shell) in a shell script charlei Shell Programming and Scripting 6 10-14-2008 03:18 PM
Help! Need to convert bash shell to perl freak Shell Programming and Scripting 0 06-19-2008 10:42 AM
Another bash shell to perl conversion freak UNIX for Dummies Questions & Answers 6 05-29-2008 01:04 PM
Converting bash shell to perl freak UNIX for Dummies Questions & Answers 4 05-29-2008 12:35 AM
What's the difference: 'nuhup cmds' Vs 'cmds &' billshu SUN Solaris 5 05-12-2004 11:01 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-19-2008
adc22 adc22 is offline
Registered User
  
 

Join Date: Nov 2008
Location: Bangalore, India
Posts: 15
Perl cmds doesn't work in Bash shell . Plz help

Hi everyone,
I have a Linux OS in my PC (older version 9). Its default shell is bash. Whenever I try to run some Perl program it throws error ! eg, if I run this simple PERL program ,

#!/usr/bin/perl

printf "\lHello \n";

$var=3 ;
printf $var;

@list=(1,2,3);
printf "@list";
------------------------ it says -
in Bash =3 command is not found and the last two lines have syntax error !

I tried it in cygwin also & got the same error (its default shell is also bash). But in my Office -PC, no error is observed.
How to tackle with this situation? should I get the latest version of Linux on which PERL can run without error ?
Please help.
  #2 (permalink)  
Old 11-19-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
first off :
change the shebang to be on the FIRST line of the perl script, in the first lefthand column.

Second: If that does not work, then
Code:
jmcnama> which perl
/usr/local/bin/perl
The which command tells you where perl lives. Change the first line to point to that:
I am making up something here, use what your system says:
Code:
#!/usr/local/bin/perl
  #3 (permalink)  
Old 11-22-2008
adc22 adc22 is offline
Registered User
  
 

Join Date: Nov 2008
Location: Bangalore, India
Posts: 15
Quote:
Originally Posted by jim mcnamara View Post
first off :
change the shebang to be on the FIRST line of the perl script, in the first lefthand column.

Second: If that does not work, then
Code:
jmcnama> which perl
/usr/local/bin/perl
The which command tells you where perl lives. Change the first line to point to that:
I am making up something here, use what your system says:
Code:
#!/usr/local/bin/perl
===================================================


Thanks jim
Which perl on my cygwin gives
cygdrive/c/Perl/bin/Perl

But even if I use this line I get the previously mentioned errors .!
  #4 (permalink)  
Old 11-22-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
please post your script - use code tags around the script text
  #5 (permalink)  
Old 11-22-2008
adc22 adc22 is offline
Registered User
  
 

Join Date: Nov 2008
Location: Bangalore, India
Posts: 15
The script is -

#!/cygdrive/c/Perl/bin/perl

$var=3 ;
printf $var;

@list=(1,2,3);
printf "@list";
---------------------------
the error i get in cygwin is -

bash: =
  #6 (permalink)  
Old 11-22-2008
adc22 adc22 is offline
Registered User
  
 

Join Date: Nov 2008
Location: Bangalore, India
Posts: 15
The script is -

#!/cygdrive/c/Perl/bin/perl

$var=3 ;
printf $var;

@list=(1,2,3);
printf "@list";
---------------------------
the error i get in cygwin is -

bash: = 3: command not found

syntax error near unexpected token '1, 2, 3'
  #7 (permalink)  
Old 11-22-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
Make sure that path to perl is in your PATH variable.
Code:
perl -e 'print "hello world\n"; '
Sponsored Links
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0