Windows cmd-使用oneliner与用户输入提示[npm]进行交互 [英] Windows cmd - Interact with user input prompt [npm] using oneliner

查看:114
本文介绍了Windows cmd-使用oneliner与用户输入提示[npm]进行交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将输入作为一行传递给用户输入提示,但是很难弄清楚如何正确地进行操作。

I am trying to pass in an input as one line to an user-input prompt, but am having difficulty working out how to do it correctly.

我我正在尝试使用 npm adduser 登录到npm( npm登录是其别名)

Specifically I am trying to login to npm using npm adduser (npm login is its alias)

当它是一个奇异值时,它可以工作,但是到目前为止,这仅使我了解: echo exampleuser | npm adduser

用户名:exampleuser
密码:
密码:npm错误! cb()从未调用过!

When it's a singular value it works but this only gets me so far: echo exampleuser| npm adduser Username: exampleuser Password: Password: npm ERR! cb() never called!

但是不幸的是,当我尝试将多个命令添加在一起时,它却出错了。例如:

echo‘exampleuser examplepassword ex@email.com’| npm adduser

echo‘exampleuser\r\nexamplepassword\r\nex@email.com’| npm adduser

echo’exampleuser&&回声示例密码&&回声ex@email.com’| npm adduser 等...

But unfortunately when I try to add multiple commands together it goes awry. Eg:
echo 'exampleuser examplepassword ex@email.com'| npm adduser or
echo 'exampleuser\r\nexamplepassword\r\nex@email.com'| npm adduser or
echo 'exampleuser&& echo examplepassword&& echo ex@email.com'| npm adduser, etc...

按照

的方式获取错误用户名:'exampleuser examplepassword'
npm WARN名称必须为小写
用户名:
用户名:npm ERR! cb()从未调用过!

任何建议将不胜感激。

推荐答案

要传递多个值,必须传递多行。 echo 无法回应换行符,因此您必须使用多个 echo

to pass several values, you have to pass several lines. echo isn't able to echo a line break, so you have to use several echo's

(
echo exampleUser
echo hisPassword
echo ex@email.com
)|npm adduser

单行显示:

(echo exampleUser&echo hisPassword&echo ex@email.com)|npm adduser

(注意:& !前没有空格!)

(note: NO space before &!)

(注意:这是传递几个参数;无法测试,如果 npm 是否实际接受它们)

(Note: this is how to pass several parameters; Can't test, if npm will actually accept them)

这篇关于Windows cmd-使用oneliner与用户输入提示[npm]进行交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆