转换UNIX Shell脚本到Windows批处理文件 [英] Convert Unix Shell Script to Windows Batch File

查看:528
本文介绍了转换UNIX Shell脚本到Windows批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个shell脚本(.SH)在Unix的作品,但我想它转换成Windows批处理文件(.bat):

I have a shell script (.sh) that works in Unix but I'd like to convert it into a Windows batch file (.bat):

cat >flog.ctl <<_EOF
LOAD DATA
INFILE '$1.log' "str ';'"
APPEND INTO TABLE flog
fields terminated by '=' TRAILING NULLCOLS
(
filename constant '$1'
,num  char
,data char
)
_EOF

sqlldr <username>/<password>@<instance> control=flog.ctl data=$1.log

我不是批处理文件也有见地,但如果答案是一些提示,而不是一个完整的解决方案,然后我想我肯定会蒙混过关。这是为了帮助一个答案,这里另一个问题

I'm not too knowledgable on batch files but if an answer is some hints rather than a complete solution then I'm sure I'll muddle through. This is to help with an answer to another question here.

推荐答案

Windows批处理文件不支持内联数据这种方式。你必须

Windows batch files do not support inlining data this way. You'll have to

ECHO firstLine > flog.ctl
ECHO additionalLine >> flog.ctl

Windows批处理文件表示使用%的迹象,即%1%。在ECHO声明变量

Windows batch files denote variables in ECHO statements using % signs, i.e. %1%.

所以,你得到的文件会是这样的:

So you're resulting file would be something like:

@ECHO OFF
ECHO LOAD DATA > flog.ctl
ECHO INFILE '%1%.log' "str ';'" >> flog.ctl
ECHO APPEND INTO TABLE flog >> flog.ctl
ECHO fields terminated by '=' TRAILING NULLCOLS >> flog.ctl
ECHO ( >> flog.ctl
ECHO filename constant '%1%' >> flog.ctl
ECHO ,num  char >> flog.ctl
ECHO ,data char >> flog.ctl
ECHO ) >> flog.ctl

sqlldr <username>/<password>@<instance> control=flog.ctl data=%1%.log 

这篇关于转换UNIX Shell脚本到Windows批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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