Perl cmds doesn't work in Bash shell . Plz help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl cmds doesn't work in Bash shell . Plz help
# 1  
Old 11-19-2008
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 !
Smilie
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  
Old 11-19-2008
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  
Old 11-22-2008
Quote:
Originally Posted by jim mcnamara
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  
Old 11-22-2008
please post your script - use code tags around the script text
# 5  
Old 11-22-2008
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  
Old 11-22-2008
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  
Old 11-22-2008
Make sure that path to perl is in your PATH variable.
Code:
perl -e 'print "hello world\n"; '

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

C shell concatenate string doesn't work

I have the following code: #!/bin/csh clear set cloud_file="/home/labs/koren/davidsr/general_scripts/MFP_10_PP_Parmas.txt" # to fill set mie_tables_dir='/home/labs/koren/davidsr/SHDOM_MAIN/MIE_TABLES/non_polo_wave_0.7_water_50R_s0.5_e25_max_70.mie' # to fill set prp_dir='${pp_dir}/pp_prp/'... (2 Replies)
Discussion started by: student_wiz
2 Replies

2. Shell Programming and Scripting

[Bash] passing variables to executable doesn't work

Bash version 4.4.20 / Ubuntu 16.0.4 Hello, I tried to write a script that gathers some data and passes them to an executable. The executed application answers with an error. The echo output in the script returns correct values. If I copy/paste the last echo command, it get's executed... (2 Replies)
Discussion started by: sushi2k7
2 Replies

3. UNIX for Beginners Questions & Answers

Bash diff date doesn't work

Hi everyone, I've an issue trying to soustracte two dates, e.g: d1=$(date -d "Nov 18, 2017" +%s) d2=$(date +%s) # Today we are 2017-11-16 echo "$(( (d1 - d2) / 86400 ))" Output: 1 I don't understand why it doesn't work. for me, it should give "18 - 16 = 2". Much appreciated... (1 Reply)
Discussion started by: Arnaudh78
1 Replies

4. Shell Programming and Scripting

Rsync in bash script doesn't work even after placing pub key in target server

Hello Friends, My bash script is like this #!/bin/bash # request Bourne shell as shell for job #$ -S /bin/bash # assume current working directory as paths #$ -cwd #$ -N rsync-copy # # print date and time date rsync -rltD --progress "ssh -i /home/myname/.ssh/id_rsa"... (4 Replies)
Discussion started by: jacobs.smith
4 Replies

5. Shell Programming and Scripting

pipe to grep doesn't work in bash script

Hi, I'm trying to write a script that checks gvfs to see if a mount exists so I can run it from network-manager's status hooks. I thought I'd pipe the output of gvfs-mount -l to grep for the particular mounts I care about. When I do this in a bash script: cmnd="gvfs-mount -l | grep -i... (4 Replies)
Discussion started by: kcstrom
4 Replies

6. Shell Programming and Scripting

Perl variables inside Net::Telnet::Cisco Module doesn't work

I am writing perl script to configure Cisco device but Variables inside Net::Telnet::Cisco Module doesn't work and passed to device without resolving. Please advise. here is a sample of script: use Net::Telnet::Cisco; $device = "10.14.199.1"; ($o1, $o2, $o3, $o4) = split(/\./,$device);... (5 Replies)
Discussion started by: ahmed_zaher
5 Replies

7. Ubuntu

set completion-ignore-case on doesn't work in bash

completion-ignore-case option doesn't work in my version: /home/user $ echo $BASH_VERSION 3.2.48(1)-release /home/user $ ls -l * -rw-r--r-- 1 user user 0 2009-10-18 00:09 somefile -rw-r--r-- 1 user user 0 2009-10-18 00:09 Somefile /home/user $ set completion-ignore-case on But when I... (2 Replies)
Discussion started by: Sapfeer
2 Replies

8. Shell Programming and Scripting

shell script, echo doesn't work

#!/bin/sh something(){ echo "Inside something" echo $1 $2 } val=$(something "Hello " "world") Output expected: Inside somethingHello world But it's not echoing. (4 Replies)
Discussion started by: cola
4 Replies

9. UNIX for Dummies Questions & Answers

bash pattern matching echo *[! '/' ] doesn't work

without using ls, just using echo so purely pattern matching I can say echo */ <-- lists directories but how would I match files? surely something like *!/ or * but neither work ? it seems like there isn't much that I can put in but surely i should be able to put any ascii... (1 Reply)
Discussion started by: james hanley
1 Replies

10. Shell Programming and Scripting

grep doesn't work within shell script?

I am trying to run the following code from a script file but it complains that syntax of (both instances of) grep is wrong. When I copy and paste it to the terminal, it is OK. Any idea what the problem might be? set i = `grep -c #define flags.h` while ($i>20) @ i-- my func (`cat... (4 Replies)
Discussion started by: barisgultekin
4 Replies
Login or Register to Ask a Question