LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-06-2011, 06:37 AM   #1
mufy
Member
 
Registered: Oct 2004
Location: Kuwait
Distribution: Currently - AIX | Previously - RHEL 4 ES, FC 10
Posts: 206
Blog Entries: 4

Rep: Reputation: 30
Perl - Porting Korn To Perl In AIX Platform


I'm in the process of brushing up my skills using Perl. As a starter, I tried to convert an existing KSH script that I wrote to Perl.

Just added:
Code:
#!/usr/bin/perl

use strict;
use warnings;
to the start of the script.

Renamed my script from bancsadm.ksh to bancsadm.pl (just for identification purpose) and called the new file. I was expecting errors, but the script fired beautifully.

I invoked the script again as:
Code:
perl bancsadm.pl
and this time a lot of errors were generated.

What I'd like to know is why the perl environment did not fire the first time even though I included #!/usr/bin/perl at the start of the script.
 
Old 01-06-2011, 07:05 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Is the .pl file marked with executable permission?
I'm also not sure if AIX gives you a "bad interpreter" error
if there's something wrong with the shebang line (line starting with #!).
So you might want to check if /usr/bin/perl is an existing, executable file (Perl interpreter).
You could for instance try calling
Code:
/usr/bin/perl
.
 
Old 01-06-2011, 07:09 AM   #3
mufy
Member
 
Registered: Oct 2004
Location: Kuwait
Distribution: Currently - AIX | Previously - RHEL 4 ES, FC 10
Posts: 206
Blog Entries: 4

Original Poster
Rep: Reputation: 30
Sure it is marked as an executable. And perl is definitely an existing executable:
Code:
root@prapbc[/home/bancsadm] #which perl
/usr/bin/perl
 
Old 01-06-2011, 07:35 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by mufy View Post
I'm in the process of brushing up my skills using Perl. As a starter, I tried to convert an existing KSH script that I wrote to Perl.

Just added:
Code:
#!/usr/bin/perl

use strict;
use warnings;
to the start of the script.

Renamed my script from bancsadm.ksh to bancsadm.pl (just for identification purpose) and called the new file. I was expecting errors, but the script fired beautifully.

I invoked the script again as:
Code:
perl bancsadm.pl
and this time a lot of errors were generated.

What I'd like to know is why the perl environment did not fire the first time even though I included #!/usr/bin/perl at the start of the script.
The item in red contradicts the item in blue.
 
1 members found this post helpful.
Old 01-06-2011, 07:39 AM   #5
mufy
Member
 
Registered: Oct 2004
Location: Kuwait
Distribution: Currently - AIX | Previously - RHEL 4 ES, FC 10
Posts: 206
Blog Entries: 4

Original Poster
Rep: Reputation: 30
I understand :-). What I meant was the script executed as a normal KSH script at first and threw errors only when I explicitly invoked the same from the CLI prefixing it with 'perl'.

Hope it makes sense now.
 
Old 01-06-2011, 08:00 AM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by mufy View Post
I understand :-). What I meant was the script executed as a normal KSH script at first and threw errors only when I explicitly invoked the same from the CLI prefixing it with 'perl'.

Hope it makes sense now.
How about putting this:

Code:
#!/usr/bin/perl

use strict;
use warnings;

warn "checkpoint";

__END__
in the very beginning and again trying

Code:
/full/path/to/bancsadm.pl
?
 
Old 01-06-2011, 08:17 AM   #7
mufy
Member
 
Registered: Oct 2004
Location: Kuwait
Distribution: Currently - AIX | Previously - RHEL 4 ES, FC 10
Posts: 206
Blog Entries: 4

Original Poster
Rep: Reputation: 30
Even now the script is firing in a perl environment only if prefixed and invoked as:
Code:
perl bancsadm.pl
and executing as a normal KSH script if invoked otherwise. Why is that?
 
Old 01-06-2011, 08:51 AM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by mufy View Post
Even now the script is firing in a perl environment only if prefixed and invoked as:
Code:
perl bancsadm.pl
and executing as a normal KSH script if invoked otherwise. Why is that?
Publish here output of

Code:
ls -ltr /full/path/to/bancsadm.pl
- of course, use real full path.

Also, publish here output of

Code:
head -1 /full/path/to/bancsadm.pl
.
...
Did you edit your script on Windows ? What does

Code:
file /full/path/to/bancsadm.pl
say ?

Last edited by Sergei Steshenko; 01-06-2011 at 08:53 AM.
 
Old 01-24-2011, 01:49 AM   #9
mufy
Member
 
Registered: Oct 2004
Location: Kuwait
Distribution: Currently - AIX | Previously - RHEL 4 ES, FC 10
Posts: 206
Blog Entries: 4

Original Poster
Rep: Reputation: 30
Please find below the information requested -
Code:
root@prapbc[/] #ls -ltr /home/bancsadm/bancsadm.pl 
-rwxrwxr--   1 bancsadm fnspr          3616 Jan 06 16:16 /home/bancsadm/bancsadm.pl

root@prapbc[/] #head -5 /home/bancsadm/bancsadm.pl 
#!/usr/bin/env perl
use strict;
use warnings;

warn "checkpoint";

root@prapbc[/] #file /home/bancsadm/bancsadm.pl
/home/bancsadm/bancsadm.pl: commands text
 
Old 01-24-2011, 07:56 AM   #10
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by mufy View Post
Please find below the information requested -
Code:
root@prapbc[/] #ls -ltr /home/bancsadm/bancsadm.pl 
-rwxrwxr--   1 bancsadm fnspr          3616 Jan 06 16:16 /home/bancsadm/bancsadm.pl

root@prapbc[/] #head -5 /home/bancsadm/bancsadm.pl 
#!/usr/bin/env perl
use strict;
use warnings;

warn "checkpoint";

root@prapbc[/] #file /home/bancsadm/bancsadm.pl
/home/bancsadm/bancsadm.pl: commands text
What does the

Code:
perl -V
command produce ?

Also, try to replace

Code:
#!/usr/bin/env perl
with
Code:
#!/usr/bin/perl
.

What does

Code:
ls -ltd /home/bancsadm
command produce ?
 
  


Reply

Tags
ksh to perl


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
LXer: Porting Perl To Python LXer Syndicated Linux News 0 09-10-2010 07:50 AM
Python to Perl porting help jamescondron Programming 1 07-08-2009 07:54 PM
Porting from AIX to MF-Express platform Bandita_Deka AIX 1 12-19-2005 07:11 AM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 09:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:21 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