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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Insecure dependency in system trying to run pscp command

Status
Not open for further replies.

redrafiki

Programmer
Oct 26, 2010
5
US
Hello, this is my very first post on this site. I'm having a problem trying to pscp some files to my computer. When I run the command formed with the parameters I got from the web form in the command prompt, it works great. But running the cgi - script gives me the error of "Insecure dependency in system while running with -T switch at...".

This is the code for my cgi - script:

#!/perl/bin/perl -wT
use CGI qw:)standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

$ENV{'PATH'} = 'C:\\Temp\\';

#Declare the variables
my $result;
my $staging_area = param('staging');
my $directory = param('directory');
my $user_id = param('userid');
my $passwd = param('passwd');
my $store = param('store');

#Attach the store directory to the diectory variable
$directory = $directory . "/" . $store;

#Set the directory where pscp.exe resides
my $pscp_dir = 'C:\\Temp\\';

#Construct the pscp command with the right arguments
my $command = $pscp_dir . "pscp.exe -pw " . $passwd . " " . $user_id . "@" . $staging_area . ":" . $directory . "/" . $store . "*.tgz " . $pscp_dir;

#Execute the command
system($command);


if ( $? == -1 )
{
$result = "command failed: $!\n";
}

print header;
print start_html("Thank You");
print h2("Thank You");
print "$result<br>\n";
print end_html;

I'm running the script in a windows server, that is why I'm using pscp. I did some testing "printing" the result command and I tried that in the command prompt and worked with no problem. I think the problem might be the user the cgi-script is running and not having permission to write on my directory. Do you know how can I solve that issue?

Thanks
 
Hello Max, I tried removing the T parameter before and I got an error: "Script timed out before returning headers"; I've found that the size of the files to retrieve is not important, I tried with a 10 bytes and with a 500 MB file, and I got the same result, the page just sits there "Waiting..."

I think the hole thing is being able to run an executable from a cgi-script in Windows.
 
print header();
print start_htm();
Print the incoming variables along with what variables you are setting.

* Make sure they have desired values.
* The directory paths should be fully defined.

Try system("$command");
 
Yes I print the resulting command and it is well formed, that is the output I'm using in the command prompt and it works correctly.

I tried you solution on the system command and I got the same message. I'm thinking somehow I cannot call cmd.exe (not having the right permissions) in order to run pscp.exe
 
That could be it. You can try running a generic command catpure the output with qx ` `.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top