Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System Command Permissions

Status
Not open for further replies.

sera

Technical User
Jun 29, 2000
360
US
Hello All,
I have searched the forum as well as the internet on this problem for a considerable amount of time. I have simplified this script to just one line. I am trying to get the system command to work on my machine. I have been able to successfully run this perl script on another machine. This makes me think I have permission problems for the system command.
Useful Information:
1. I am running this perl script from the command prompt.
2. I am trying to run it on a Windows XP machine.
3. I am only having problems with system, exec....
4. This works on another machine
5. The error code system returns is 65280
6. The script I am trying to run....

Code:
#!/usr/bin/perl
system "copy C:\\Perl\\eg\\PerlEx\\testSystem.pl delete.pl";


Has anyone experienced this problem before?


Sera
 
If you are running on Unix you will need to change the command to "cp"

Also, try:

system('copy', 'file1', file2');


Or you can...

use File::Copy;
copy('src_file', 'dest_file');

The last is the best option since it is generally a cross-platform implementation.
 
Sorry, I have been away from my desk...

In my previous post, I stated that I am running this program via WindowsXP. The real problem here is that I am actually needing to run many more system commands than just copy. So your comment of using File::Copy is really not going to solve my problem. Also, in my previous post I stated that this program runs fine on one machine and doesn't run on one machine.

One thing I did not mention was that this program was running fine and one day it just stopped working. It is definitely doing everything else but system commands. I really think this problem is due to a permission error or perhaps a policy error. Perhaps the perl program needs certain permissions to run cmd.exe?

Thanks

Sera
 
have you tried adding the absolute path to the second file?

 
Just did, that did not work.

Sera
 
Have you tried using backticks instead of system?
 
Yep, sure have. I researched this problem for about a day online before I posted. That was one of the suggestions.

This program worked before...works on another machine. It has to be a permissions problem.

Sera

Sera
 
another possibility is running it under cmd.exe as opposed to command.com.
Code:
@results=`set path`;
foreach (@results) { print; }
Put that snippet in a file, and run it from the command line, if it's blank you're most likely in command.com, as opposed to cmd.exe

HTH

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
What is the program supposed to do?

@results = 'set path'

is that supposed to be 'the copy command'?



Sera
 
on any machine, the command within the backticks (``, not '') will run at the OS level, and return the results to the array @results;

same as
Code:
@results=qx("set path");
print @results;

This will tell us what directories are in your path for the command console you're running under.

If you run this under cmd.exe, you should expect a result like
Path=C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\WinSCP3\;E:\Program Files\Common Files\GTK\2.0\bin;E:\Program Files\Symantec\pcAnywhere\;"C:\Program Files\Symantec\Norton Ghost 2003\";C:\Program Files\QuickTime\QTSystem\;E:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;E:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;E:\Program Files\Microsoft Visual Studio\Common\Tools;E:\Program Files\Microsoft Visual Studio\VC98\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH


Hope that makes sense
/aside, I should check if any of that stuff is still installed :confused:

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Well it just doesn't return anything. I am supposed to put that in exactly as you pasted it? Or am I supposed to set a path? Either way, I tried it both ways and it prints nothing.

Sorry...i am being a pain...but I just don't get it. I have seen other people have similar problems to me out there in search land ... but none of them post their solution.



Sera
 
If it returns nothing, then you're running your scripts under command.com, and NOT cmd.exe, which is what you should be doing, as this is the environment with all the path variables set.

Start->Run->Cmd.exe

is not the same as the Windows Command Prompt Command.com

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
So how do I change that? What is cmd.com? If I try to run cmd.com from the start->run it errors with Windows cannot find cmd.com...

Sera
 
Cmd.exe (not COM), just type cmd and press enter in the run box!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
While you're running around in that Windows Shell (cmd.exe), take a look at the ComSpec environmental variable. Mine reads:
Code:
ComSpec=C:\WINDOWS\system32\cmd.exe
I'm guessing yours points towards command.com.
 
Boy do I wish that was the problem. I checked out my environment variables...I am cutting and pasting the result of comspec here

ComSpec=C:\WINDOWS\system32\cmd.exe

I am definitely pointing towards cmd.exe.

Any other ideas?

Sera
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top