Can't run Perl script from outside directory

L

lonewolfcsu

I'm having a problem running a perl script and I'm completely
dumbfounded on the reason.

For sake of argument, let's say the script is located at
/blah/blaugh/blaw/script.pl.

The following works:
$ pwd
/app/home/mylogin
$ cd /blah/blaugh/blaw
$ perl script.pl

This, however, does not:
$ pwd
/app/home/mylogin
$ perl /blah/blaugh/blaw/script.pl

Any thoughts as to why not? I'm stumped.
 
X

xhoster

I'm having a problem running a perl script and I'm completely
dumbfounded on the reason.

For sake of argument, let's say the script is located at
/blah/blaugh/blaw/script.pl.

The following works:
$ pwd
/app/home/mylogin
$ cd /blah/blaugh/blaw
$ perl script.pl

This, however, does not:
$ pwd
/app/home/mylogin
$ perl /blah/blaugh/blaw/script.pl

Any thoughts as to why not? I'm stumped.

What you do you mean by "works"? What do mean by "does not [work]:"?

Xho
 
L

lonewolfcsu

In this case, it's just a test script to try and diagnose the problem.

#! /usr/bin/perl

open(LOG, ">>/blah/blaugh/blaw/script.log");
print "Success!\n";
print LOG "Success!\n";
close(LOG);
exit(0);


When run from the directory the script is in, "Success!" appears both
in the log and on the screen. When run from some other directory, it's
not printed at all. Yet I don't get any kind of error message.
 
X

xhoster

In this case, it's just a test script to try and diagnose the problem.

Is the space in the shebang line a problem?
#! /usr/bin/perl

## You should ask perl for help before asking us for help!
use strict;
use warnings;

## See if the program even starts
warn "Yeah, I started";

## You should ask perl for help before asking us for help!
open(LOG, ">>/blah/blaugh/blaw/script.log")
or die "Couldn't open $!";

## I don't normally check print, but in a pinch:
print "Success!\n" or warn "straight print $!";
print LOG "Success!\n" or warn "LOG print $!";
close(LOG) or die "Close failed $!";
exit(0);

When run from the directory the script is in, "Success!" appears both
in the log and on the screen. When run from some other directory, it's
not printed at all. Yet I don't get any kind of error message.

You didn't ask for most kinds of error messages!.

Xho
 
L

lonewolfcsu

Ok, ignore this whole thread...I'm an idiot. I was typing the wrong
path to the script. It was a valid path, so there was a script
running. It was just the wrong path.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top