In the following code, I am trying to transfer ssh to another computer and check if this file exists or not.
If the file exists, then I need to check whether the person accessing the file is the creator of this file, that is, its username is in the log file.
If present, then I need to delete this file. How can I achieve this with single sign-on ie, the user enters the password only once.
$user = $ENV{USER}; $il_check_cmd = "cat $shared_il_path/$il_name/info/.info_cat.log"; my $ssh_delete = Net::SSH::Perl->new($hostname, protocol => '1,2', debug => 0, interactive => 1) ; $ssh_delete->login($username, $password); ($stdout,$stderr,$exit) = $ssh_delete->cmd("$il_check_cmd"); if((defined $stderr) && ($stderr =~ /No such file or directory/)) { print "-E- $RUNCMD: \"$il_name\" you have entered does not exist in \"$shared_il_path\"!! !\n"; print "-E- $RUNCMD: or\n"; print "-E- $RUNCMD: \"$il_name\" does not contain \".info_cat.log\" file!!!\n"; print "-E- $RUNCMD: Exiting...\n"; exit; } @content = split(/ /,$stdout); chomp($user_e = shift(@content)); if($user_e =~ /\b$user\b/) { print "This is the user who created the file"; //then remove the $shared_il_path/$il_name/info/.info_cat.log }
source share