LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-05-2008, 05:53 AM   #1
TalkingMarble
Member
 
Registered: May 2008
Location: Deventer, The Netherlands
Distribution: CentOS 5.0
Posts: 50

Rep: Reputation: 17
Cool Executing Perl Script


Hello,

I'm new to linux/perl, and i have a little problem executing a perl script.

#!/usr/bin/perl -w
#

if ($^O eq "MSWin32")
{
$strProgram = "C:/Program Files/VMware/VMware VmPerl Scripting API/vmware-cmd.bat";
open(STDOUT, ">>C:\\VMware.log" );
open(STDERR, ">>C:\\VMware.log" );
}
else
{
$strProgram = "/usr/bin/vmware-cmd";
open(STDOUT, ">>/home/batch/VMware.log" );
open(STDERR, ">>/home/batch/VMware.log" );
}

$time = localtime(time);
die "Text" unless($ARGV[0]);

foreach (@ARGV) {
if ($_ eq "DebianTracVM")
{
$strVM = "C:\\TracVM\\TracVM\\Other Linux 2.4.x kernel.vmx";
}
elsif ($_ eq "Test")
{
$strVM = "/vmware/Test/Other Linux 2.6.x kernel.vmx";
}
else
{
die "Text"
}

@args = ($strProgram,$strVM,"start","hard");

$time = localtime;
print "$time Virtual Machine $_: ";
system (@args);

$time = localtime;
print "$time Virtual Machine $_: ";
@args = ($strProgram,$strVM,"getstate");
system (@args);
}

When i execute the perl script with "PowerOn.pl Test", i am getting the following error : -bash: PowerOn.pl: command not found.

Can anybody tell why i get this message?

When i execute the same script with "perl PowerOn.pl Test" everything works just fine.

Any help will be appreciated.

TIA
 
Old 08-05-2008, 08:24 AM   #2
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
Not in PATH

How about ./PowerOn.pl Test ?
 
Old 08-05-2008, 08:30 AM   #3
TalkingMarble
Member
 
Registered: May 2008
Location: Deventer, The Netherlands
Distribution: CentOS 5.0
Posts: 50

Original Poster
Rep: Reputation: 17
Starting the script with ./ works fine. What is the function of ./ when starting the script.
 
Old 08-05-2008, 08:38 AM   #4
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
env | grep PATH

If your current directory is not there, then using ./ provides the path to your perl script. There are bits of wisdom of not putting all directories in your PATH, especially ".". This avoids security holes.

You've obviously chmod'd your perl script so it is executable,
chmod 777 PowerOn.pl
 
Old 08-05-2008, 09:33 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,245

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
There's (usually) no need to let other people use your script, so make that

chmod u=rwx,go= PowerOn.pl
 
  


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
Executing unix commands from perl script running on Windows. harishkrishnan Programming 1 03-05-2008 12:48 AM
Executing Javascript in Perl rigel_kent Programming 1 08-03-2006 10:01 AM
executing perl script through .forward file skverma_in Linux - Newbie 3 10-21-2004 08:24 AM
executing perl script through .forward file skverma_in Linux - General 0 10-18-2004 06:06 AM
Executing Perl Programs 1huskerfan Programming 3 01-06-2002 08:39 PM


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