Windows:在一行中运行多个命令时出现问题,逐个运行时则没有问题。

huangapple go评论70阅读模式
英文:

Windows: Issue coming when running multiple commands in 1 line, and not when running then one by one

问题

以下是翻译好的部分:

当在Windows命令行上运行以下命令时,会出现问题:

set P4USER=ARPIT & set P4PORT=opl:p4dia:1934 & set P4CLIENT=opl_reg_591 & p4 client -o

错误:

Perforce客户端错误:
    连接到服务器失败;请检查$P4PORT。
    未找到指定的类。

但是当在cmd上逐个运行这些命令时,没有问题:

set P4USER=ARPIT 
set P4PORT=opl:p4dia:1934
set P4CLIENT=opl_reg_591
p4 client -o

为什么会这样?

我想将这4个小命令在一行中运行,因为我必须在脚本中的反引号中使用它们。如何解决这个问题?

英文:

When running following command on windows command line, issue is coming:

set P4USER=ARPIT & set P4PORT=opl:p4dia:1934 & set P4CLIENT=opl_reg_591 & p4 client -o

Error:

Perforce client error:
        Connect to server failed; check $P4PORT.
        The specified class was not found.

But when running these command, one by one, on cmd, no issue is coming:

set P4USER=ARPIT 
set P4PORT=opl:p4dia:1934
set P4CLIENT=opl_reg_591
p4 client -o

Why so?

I want to run these 4 mini commands in 1 line, as I have to use them in a backtick in a script. How can this issue be resolved?

答案1

得分: 0

"Magoo 的回答 (为每个被设置的变量设定“P4USER=ARPIT” ) 是正确的。

此外,在这种情况下可以使用以下内容:

p4 -u ARPIT -c opl_reg_591 -p opl:p4dia:1934 client -o"
英文:

@Magoo answer (set "P4USER=ARPIT" for each of the variables being set. Your current syntax includes the space before the & into the value assigned. Quoting as shown makes the assignment required) is right.

Also, the following can be used in this context:

p4 -u ARPIT -c opl_reg_591 -p opl:p4dia:1934 client -o 

huangapple
  • 本文由 发表于 2023年3月1日 16:41:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75601315.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定