-3

I have written a perl script which running fine in my system but not working in some other system.

It is showing error "can't execute ...... at line 1". everything is set up. I have tested in version 5.8.2 and working fine. But in 5.8.6 it is not working. While compile this code I got that Archive/Tar.pm is missing.

I have checked in my system perl lib folder there is no such Folder/module. Also I didnt get any result for perldoc -lm Archive::Tar in my system but still it is running fine.

Can you let me know what might be the possible problem ?

First line :: #! C:\system\Perl

This program is for windows

r-developer
  • 517
  • 1
  • 8
  • 21
  • The perl interpreters location is correct in the first line? For example if your first line looks like `#! /usr/bin/perl`, is the interpreter there? – Lajos Veres Feb 05 '14 at 17:03
  • this is script for windows. – r-developer Feb 05 '14 at 17:10
  • This first line is suspicious anyway. Is the interpreter this: C:\system\Perl ? – Lajos Veres Feb 05 '14 at 17:16
  • @rajarshi it doesn't matter. #!/usr/bin/perl works on Windows – Dr.Avalanche Feb 05 '14 at 17:17
  • I am confused why it is saying that Archive/Tar.pm is missing ? or Cant execute .... line 1. for other systems – r-developer Feb 05 '14 at 17:20
  • How do you run the script? – choroba Feb 05 '14 at 17:21
  • perl script_name. Note: this is working in my system – r-developer Feb 05 '14 at 17:24
  • You don't tell us how you transfered this between systems. Perhaps you've messed up the line endings and can't find the perl interpreter. Use a sensible text editor like Notepad++ to ensure that line endings are correct. #!/usr/bin/perl Is a valid shebang line on Windows. – Dr.Avalanche Feb 05 '14 at 17:27
  • see it is .pl script and in windows I can easily copy paste a file and run – r-developer Feb 05 '14 at 17:31
  • @rajarshi you post no code, you don't even post the full error. Make some effort – Dr.Avalanche Feb 05 '14 at 17:45
  • I cannot post actual code here as they are in my office system. I dont feel there is any problem with my script. I didnt get why it is saying cann't locate Archive/Tar.pm in @INC. I have compare lib folder both my system and other system, there is no such folder/module for Archive, but still it is running in my system and not running with other system. even if I run perl -c script, in my system I getting Debug OK, but other system is showing the above error "cann't locate Archive/Tar.pm in @INC"; – r-developer Feb 05 '14 at 17:56
  • @rajarshi: Just install `Archive::Tar`. – Borodin Feb 05 '14 at 19:00

3 Answers3

2

Try running dos2unix on your script. It probably has Carriage Returns in the first line.

dos2unix yourscript

You can check with

cat -vet yourscript

CR shows up as ^M.

Also, try running:

which perl

and make sure that your first line matches the answer.

Try running the script using:

perl yourscript

rather than

./yourscript
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
0

Are you sure the first line is terminated correctly for your OS (for example, Linux hates CR+LF line terminators... :-)

MarcoS
  • 17,323
  • 24
  • 96
  • 174
0

If Perl is saying that Archive::Tar is missing then it is probably right. Don't argue with it - just install the module.

Borodin
  • 126,100
  • 9
  • 70
  • 144