Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何在批处理文件中调用多行?_Batch File_Amazon Ec2 - Fatal编程技术网

Batch file 如何在批处理文件中调用多行?

Batch file 如何在批处理文件中调用多行?,batch-file,amazon-ec2,Batch File,Amazon Ec2,我想调用批处理文件中的多行,我如何才能做到这一点 (这是我想呼叫的电话线) 如何在批处理文件中将这两行一起调用 这是批处理文件现在是什么 @echo on echo "file init call ec2-describe-spot-price-history -H --instance-type t1.micro --start-time 2014-05-29T16:00:00 --end-time 2014-05-29T017:00:00 --availability-zone us-e

我想调用批处理文件中的多行,我如何才能做到这一点

(这是我想呼叫的电话线)

如何在批处理文件中将这两行一起调用

这是批处理文件现在是什么

@echo on

echo "file init

call ec2-describe-spot-price-history -H --instance-type t1.micro --start-time 2014-05-29T16:00:00 --end-time 2014-05-29T017:00:00 --availability-zone us-east-1a  >> out.txt

echo "file written"

FOR /f "tokens=1 delims=" %%i in (out.txt) do echo %%i

echo "file done"

pause 
批处理文件的输出:

Type    Price   Timestamp   InstanceType    ProductDescription  AvailabilityZone
SPOTINSTANCEPRICE   0.006100    2014-05-29T09:29:08+0530    t1.micro    Windows us-east-1b
SPOTINSTANCEPRICE   0.006100    2014-05-29T04:52:09+0530    t1.micro    SUSE Linux  us-east-1b
SPOTINSTANCEPRICE   0.003100    2014-05-29T04:52:08+0530    t1.micro    Linux/UNIX  us-east-1b

不确定这是你想要的,试试看

@echo off
    setlocal enableextensions enabledelayedexpansion

    echo file init

    set "filter="
    (   for %%a in ( us-east-1a us-east-1b ) do (
            call ec2-describe-spot-price-history -H ^
                    --instance-type t1.micro ^
                    --start-time 2014-05-29T16:00:00 ^
                    --end-time 2014-05-29T017:00:00 ^
                    --availability-zone %%a | findstr /r /c:".*!filter!"
            if not defined filter set "filter=t1.micro"
        )
    ) > out.txt

    echo "file written"

    FOR /f "tokens=1 delims=" %%i in (out.txt) do echo %%i

    echo "file done"

    pause 

错误:Client.InvalidParameterValue:无效的可用性区域:[%a]@user323041,
%%a
for
循环的可替换参数,应替换为中的
中的一个值(
set.
%a
不应到达
ec2-..
调用。它区分大小写,因此请确保您没有同时使用
%a
%a
@echo off
    setlocal enableextensions enabledelayedexpansion

    echo file init

    set "filter="
    (   for %%a in ( us-east-1a us-east-1b ) do (
            call ec2-describe-spot-price-history -H ^
                    --instance-type t1.micro ^
                    --start-time 2014-05-29T16:00:00 ^
                    --end-time 2014-05-29T017:00:00 ^
                    --availability-zone %%a | findstr /r /c:".*!filter!"
            if not defined filter set "filter=t1.micro"
        )
    ) > out.txt

    echo "file written"

    FOR /f "tokens=1 delims=" %%i in (out.txt) do echo %%i

    echo "file done"

    pause