-1

I want to send some commands to windows command prompt using 'PERL' script. the command is: putty.exe -ssh -2 -l username -pw password "ip address" this command will open an SSH session (console)to the mentioned ip address (server) for me. after getting the new console, I want to pass commands to and perform operations in the new console.How can I do that as well?

Please help

4
  • 1
    Have a look here stackoverflow.com/questions/2848725/… You will probably want to use the Perl Expect module and then the "interact" command that lets you interact with whatever you have spawned. Commented Mar 12, 2014 at 10:44
  • That should be an answer, imho. There is really not a lot more to say. Commented Mar 12, 2014 at 10:53
  • reposted elsewhere [perlmonks.com/?node_id=1078146] Commented Mar 13, 2014 at 9:58
  • hello doctor, perl monk link is 404. Commented Sep 28, 2015 at 9:01

1 Answer 1

0

You can use 'system' or 'exec' command.

system:

@args = ("command", "arg1", "arg2");
system(@args) == 0
    or die "system @args failed: $?"

http://perldoc.perl.org/functions/system.html

exec:

exec '/bin/echo', 'Your arguments are: ', @ARGV;
exec "sort $outfile | uniq";

http://perldoc.perl.org/functions/exec.html

Please notice the difference between them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.