【问题标题】:Convert Bash script to Perl/VBS/any other windows compatible language [closed]将 Bash 脚本转换为 Perl/VBS/任何其他 Windows 兼容语言 [关闭]
【发布时间】:2012-04-10 23:42:53
【问题描述】:

我得到了一个用于将文件从沙盒传输到主机的 bash 脚本。 沙盒目录中的文件只有在它们更年轻时才会被传输,这意味着它们之前已经被“触及”过。不幸的是,cygwin在windows下造成了麻烦,所以我需要另一种语言的脚本,或者我需要在windows下像cygwin一样工作的东西。 该脚本只有大约 20 行,但我不知道如何将其转换为另一种语言(尤其是 touch、make、gcc、getopts、set -e 等命令) 如果有人发现这很容易做到并转换它,我会很高兴:

# EXITING SCRIPT IF ERROR OCCURS
set -e

FORCE=false
JUSTPRINT=

# if parameter -f is given, force to transfer all files(no matter if new or not)
# if -n is given checking files
while getopts fn opt 2>/dev/null
do
case $opt in
f) FORCE=true ;;
n) JUSTPRINT="-n" ;;
?) ;;
esac
done

# deleting parsed options from command line
shift `expr $OPTIND - 1`


# refresh files that came with -f
if [ \( $FORCE = true \) -a \( $# -gt 0 \) ]
then
touch -c $@
fi

# Targets (dummy files for timestamp)
TARGETS=`for filename
     do
       if [ -f $filename ]
       then
         echo "../transport_dummies/\`basename $filename\`.dum"
       else
         echo "$filename"
       fi
     done`

# call script directory
echo $0
cd `dirname $0`

# creating sysfilterL.exe
if [ ! -f sysfilterL ]
then
echo "sysfilterL is created."
gcc sysfilter.c -o sysfilterL
fi

# Call Transport-Makefile with target
if [ $# -gt 0 ]
then
make --warn-undefined-variables $JUSTPRINT -f transportDE.mk reset $TARGETS
send_queueed
else
make --warn-undefined-variables $JUSTPRINT -f transportDE.mk
fi

【问题讨论】:

  • 为什么每个人都给我不好的名声而不是帮助我?
  • 因为这不是一个“为我工作”的网站。你需要提出更具体、更容易回答的问题。阅读the FAQ
  • 有 Windows bash 端口,例如在 cygwin,msys 中。

标签: perl bash powershell vbscript batch-file


【解决方案1】:

您可以将 shell 脚本转换为批处理文件,此处介绍:How do I convert a bash shell script to a .bat file?

这里还列出了 bash 和批处理中的相应命令:http://tldp.org/LDP/abs/html/dosbatch.html

【讨论】:

  • 是的,有很多人可以做到。例如,您可以。阅读链接页面。明白它。尽可能转换。然后回到这里,就您无法弄清楚的命令提出具体问题....或者聘请某人为您完成工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-16
  • 1970-01-01
  • 2012-10-20
  • 2011-10-01
相关资源
最近更新 更多