Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Can't run Perl script from outside directory

Reply
Thread Tools

Can't run Perl script from outside directory

 
 
lonewolfcsu@gmail.com
Guest
Posts: n/a
 
      03-22-2006
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.

--
Dave "LoneWolf" Savitsky

 
Reply With Quote
 
 
 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      03-22-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
 
 
 
lonewolfcsu@gmail.com
Guest
Posts: n/a
 
      03-22-2006
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.

--
Dave "LoneWolf" Savitsky

 
Reply With Quote
 
xhoster@gmail.com
Guest
Posts: n/a
 
      03-22-2006
(E-Mail Removed) wrote:
> 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

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
lonewolfcsu@gmail.com
Guest
Posts: n/a
 
      03-22-2006
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.

--
Dave "LoneWolf" Savitsky

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 8.34 I {changed directory, modified my environment} in a perl script. How come the change disappeared when I exited the script? How do I get my changes to be visible? PerlFAQ Server Perl Misc 0 03-12-2011 11:00 AM
help with pix inside->outside + dmz->outside + inside->outside->dmz Jack Cisco 0 09-19-2007 01:57 AM
Is it possible to run a perl script in a machine where Active perl is not installed. hara Perl Misc 6 05-27-2006 12:07 PM
how to run perl script from a perl script? anywherenotes@gmail.com Perl Misc 6 04-13-2005 11:19 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments