Sending Windows Terminal Commands Via Perl - perl

I am trying to use the query terminal server command, but Perl keeps coming back with this error:
'query' is not recognized as an internal or external command,
operable program or batch file.
If I enter the query command directly into the command prompt I am able to use it, however all of these attempts via Perl result in the above error:
exec("query /help");
system("query /help");
`query /help`;
I'm guessing it has to do with the way Perl creates a new shell to send commands. Is there a way to have it send directly within the same command shell I am executing the Perl script in?

Well, I've just tried it on my system with:
print system ( "query /help" );
And that works. So my guess might be - query isn't in the path when you're using perl.
Failing that though - I'd suggest trying cmd /c query /help

Related

Python os.system & subprocess do not recognize Microsoft's ie4uinit.exe

I'm trying to call ie4uinit from a python script so that I can update the icon in my task bar. ie4uinit.exe -ClearIconCache does just that, however whenever python calls it, either with subprocess.call or os.system, the following error comes up and the program is not called.
"ie4uinit.exe" is not recognized as an internal or external command,
operable program or batch file.
I have tried giving the full path location i.e.
"C:\Windows\System32\ie4uinit.exe"
Same result.
I have even made a .bat to abstract the call.
I suspect the problem is stemming from a difference in permissions between calling the command from the command line, and calling it through python.
But I don't know how.

unix command './' is not recognized

I'm using Matlab 2013a. The unix command './' doesn't work in matlab and returns the following error.
>> unix('./makeBeamxy.s')
'.' is not recognized as an internal or external command,
operable program or batch file.
Is there a way to solve it? I'm actually running this command from cygwin. But the 'system' command doesn't work very well because after I run this command, I need to keep the cgywin window open to run another command so that I can execute the file.
Try
unix(fullfile('.','makeBeamxy.s'))

perl command prompt with arguments

Is it possible to start a command prompt from perl script using Win32::Process::Create package?
I am trying to start DOORS from perl script. The executable is present in C:\Program Files\DOORS\bin\runDOORS9.rck.
I need to start the runDOORS9.rck with the argument COL9 to change the Database.
Try the good old system() function. On Windows it would use the cmd.exe, the system shell, to execute the command.
Since what you try to launch doesn't seem to be an .exe file, potentially you would have to use the start command of the cmd.exe.
For example:
system(qq{start "" "C:\Program Files\DOORS\bin\runDOORS9.rck" COL9});
(The first "" is required due to quirky argument parsing of the Window's shell commands. See help start for more information.)

Run a perl script inside another script using ssh

I have a perl script where I need to connect to another machine using ssh and there run another perl script. I tried using this line:
system("ssh $admin_server 'perl /Perl/scripts/capture_server_restarts_gse.pl $month $date'");
But everytime the script gets to that line, I get the prompt for the remote machine and the script doesn't run.
How can I fix this so the script runs automatically on the other machine without showing the prompt.
Note: I don't need the password and user to connect to the remote machine we already solved that.
Why not copy your public key onto the other machine ? That way you'll be pre-authorised.
Here are the instructions on how to do this using ssh-keygen
Otherwise you have to feed ssh with your password, and that's tricky since ssh normally takes input from a tty and you have to configure your script with the password.
The SSH server may be configured to run always some custom shell instead of the command passed from the client.
Try just running some simple command from the command line, i.e.:
ssh server ls
A less likely possibility is that the perl variables interpolated into the system argument could contain some shell metacharacters requiring better escaping. For instance, a semicolon inside $admin_server.

DBD::Oracle fails to connect with OCIEnvInit when called when accessed through webserver only

I have a simple perl script that uses DBD::Oracle to run a query and print the results. It works fine from the command line, but I also have a PHP script that runs it and reads the output. When the PHP script is accessed through apache it fails to connect, with the error "OCIEnvInit".
I've tried creating a shell script that re-sets all the environment variables available in the shell but that didn't help, and I also tried setting the debugging output for DBI but got nothing. What could cause this error when the script does work?
Are you sure that ORACLE_HOME and other relevant environment variables (e.g., LD_LIBRARY_PATH) that are set in your shell when you run the script from the command line are also set to the same values in the apache/PHP process?