开发者

Interactive cmd.exe in Windows

开发者 https://www.devze.com 2022-12-21 22:25 出处:网络
Is it possible to create an interactive cmd under Windows? I am looking for a scripting solution to login to a server remotely which prompts password entering.

Is it possible to create an interactive cmd under Windows?

I am looking for a scripting solution to login to a server remotely which prompts password entering.

Take SSH as an example. A normal user will do the following at a command line window:

C:>ssh2 user@server.com "echo Hello"
user's password: ********
Hello
开发者_开发知识库

The second line, which prompts password entering, must be manually entered by a user. Stdin redirection does not work, for example,

ssh2 user@server.com "echo Hello" < password.txt  # not working

Therefore, I am looking for a script, which can impersonate a user. In Linux we can use expect, for example:

#!/usr/bin/expect

spawn ssh user@server.com "ls"
expect *assword:
send "password\r"

I am looking for similar stuffs in Windows environment.

Update: If PowerShell can do the same, can someone paste a sample script? Thanks.


This problem is solved.

Use a powershell that creates a Process object and play with that object.

0

精彩评论

暂无评论...
验证码 换一张
取 消