简体   繁体   English

作为传递的参数执行perl脚本

[英]execute perl script as passed argument

Im trying to execute a perl script as a passed argument from the command line. 我试图执行perl脚本作为从命令行传递的参数。 I compiled ac file and named it "Test", so trying to pass an argument I try this 我编译了一个ac文件,并将其命名为“ Test”,因此尝试传递一个参数

>Test perl -e "print qq{A\n}x500"

which I want to mean, run Test file and pass 500 A's, but it seems to not be working 我想说的是,运行测试文件并通过500 A,但似乎无法正常工作

Why do you think it should work? 您为什么认为它应该起作用? It runs Test and passes 3 arguments to it - perl , -e , "print qq{A\\n}\\x500" . 它运行Test并将3个参数传递给它perl-e"print qq{A\\n}\\x500" In bash it would be: 在bash中将是:

Test `perl -a "print qq{A\n}x500"`

For windows, there is no simple way to get a programs output as a variable or pass it to another command directly. 对于Windows,没有简单的方法来获取程序输出为变量或将其直接传递给另一个命令。

See this post , it describes how set a commands output to a variable. 请参阅此文章 ,它描述了如何将命令输出设置为变量。

Try using a pipe, you were latterly passing perl -e "print qq{A\\n}x500" to Test . 尝试使用管道,您随后将perl -e "print qq{A\\n}x500"传递给Test

Example of using a pipe : 使用管道的示例:

perl -e "print qq{A\n}x500" | Test

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM