将.sh转换为.bat

时间:2016-06-17 16:22:30

标签: bash shell batch-file

我有一个.sh文件,我想将其转换为.bat文件。下面你可以看到我的shell脚本,下面是我将shell脚本转换为批处理文件的可悲尝试。我能够隐藏一些零件,但其他零件"难倒"我,就像试图将node pong.js $1命令的输出回显到__pongjs_output.txt

# Run a .php file both on pong.js and php and diff the output.

# Run on pong.js
node pong.js $1 > __pongjs_output.txt

# Run on node and replace some property names.
php $1 > __php_output.txt

echo "$1:"
diff __pongjs_output.txt __php_output.txt && echo "ok"

rm __pongjs_output.txt __php_output.txt

我尝试将shell文件转换为批处理文件:

@ECHO off
REM Run a .php file both on pong.js and php and diff the output.

REM Run on pong.js
ECHO node pong.js %1 > __pongjs_output.txt

REM Run on node and replace some property names.
ECHO php %1 > __php_output.txt

ECHO %1:
FC __pongjs_output.txt __php_output.txt
IF errorlevel 0 ECHO ok

DEL __pongjs_output.txt __php_output.txt

1 个答案:

答案 0 :(得分:2)

试试这个(从节点和php之前删除ECHO):

@ECHO off
REM Run a .php file both on php.js and php and diff the output.

REM Run on pong.js
node pong.js %1 > __pongjs_output.txt

REM Run on node and replace some property names.
php %1 > __php_output.txt

ECHO %1:
FC __pongjs_output.txt __php_output.txt
IF errorlevel 0 ECHO ok

DEL __pongjs_output.txt __php_output.txt
相关问题