LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 11-28-2007, 09:59 PM   #1
littletransformer
LQ Newbie
 
Registered: Nov 2007
Posts: 18

Rep: Reputation: 0
Unhappy how to use perl.exe in shell script


I try to add a line "/perl/bin/perl.exe a.pl" in a shell script named convert.sh,but it return "/perl/bin/perl.exe:cannot execute binary file"when I execute it.
 
Old 11-29-2007, 04:04 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,456

Rep: Reputation: 104Reputation: 104
i assume you are working on a *nix system. Probably the path to perl is sth like /usr/bin/perl or /usr/local/bin/perl. If the file has an "exe" extension it is probably for doze and maybe needs to be exchanged.
If you ar working on windows...good luck
 
Old 11-29-2007, 04:08 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,314

Rep: Reputation: 175Reputation: 175
give us a clue,
windows?
linux?

activerPerl?
 
Old 11-29-2007, 09:59 AM   #4
littletransformer
LQ Newbie
 
Registered: Nov 2007
Posts: 18

Original Poster
Rep: Reputation: 0
thanks for your help.

thank you for your help.
I have sucessfully solved the problem.as I am a new user of linux.I have mistake the windows file formt for the linux system's. so I finally figure it out by using "which perl" to find the executable compiler.
 
Old 11-30-2007, 02:07 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Just put the proper path as the first line in the Perl prog file and chmod u+x (like a shell script)
IOW, No need to invoke it with

/usr/bin/perl a.pl

Just make the first line of a.pl like this:
#!/usr/bin/perl -w

BTW, always use:

use strict;

in all your Perl progs.

Last edited by chrism01; 12-01-2007 at 07:56 PM.
 
Old 11-30-2007, 03:50 AM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,314

Rep: Reputation: 175Reputation: 175
Quote:
Originally Posted by chrism01 View Post

BTW, always use:

use strict;

in all your Perl progs.
unless it's a very small one


also, I reckon, it is often better to use warnings; rather than -w
as the -w will propogate into called packages; giving warnings
out of your control, whereas the use will not.
 
Old 12-01-2007, 07:59 PM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Well, I've always used -w and don't remember seeing an issue with that... maybe I'm just lucky
I also always use
use strict;
even in small ones because they often become larger and (more importantly) it's a good habit.
Also, I use a temp file eg test.pl to check some ides or fiddly syntax before inclusion in the real prog.
If I leave off strict/-w in that, I get bitten later in the real prog, so I don't do that ...
 
Old 12-03-2007, 04:14 AM   #8
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,314

Rep: Reputation: 175Reputation: 175
true, the -w just for info though.


the debugger is OK too for testing stuff. almost like the interactive python or lisp.
 
  


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
Using a perl script as a User's Shell john_b Linux - Security 4 07-28-2007 05:22 AM
how to run a shell script in the perl script sharad Linux - General 1 05-24-2006 04:23 AM
reading idle time with perl/shell script daryl314 Linux - General 1 12-27-2004 02:11 PM
Shell Script, C, C++, or Perl ? mrpc_cambodia Programming 5 08-12-2004 11:18 AM
how to find the pid of a perl script from shell script toovato Linux - General 1 12-19-2003 07:25 PM


All times are GMT -5. The time now is 02:26 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration