小编Sie*_*ile的帖子

如何编写脚本以输出 html 文件?

我在这个脚本中做错了什么?

#!/bin/bash

cat > /tmp/flash-viewer.htm <<- _EOF_
<HTML><HEAD><TITLE>Flash Viewer</TITLE></HEAD><BODY>
<object width=\"1280\" height=\"720\" data=\"$1\"></object>
</BODY></HTML>
_EOF_

if [ -n $BROWSER ]; then
  $BROWSER '/tmp/flash-viewer.htm'
elif which xdg-open > /dev/null; then
  xdg-open '/tmp/flash-viewer.htm'
elif which gnome-open > /dev/null; then
  gnome-open '/tmp/flash-viewer.htm'
else
  echo "Could not detect the web browser to use."
fi
Run Code Online (Sandbox Code Playgroud)

该脚本给出了这些错误:

joe@U13:~/Script$ ./html-flash-viewer.sh "/home/joe/video.swf"
/tmp/flash-viewer.htm: line 1: <HTML><HEAD><TITLE>Flash: command not found
/tmp/flash-viewer.htm: line 2: <object: command not found
/tmp/flash-viewer.htm: line 3: </BODY></HTML>: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我缺少某种转义序列吗?我已经尝试使用 \ 来转义 …

bash scripts html cat

1
推荐指数
1
解决办法
5861
查看次数

标签 统计

bash ×1

cat ×1

html ×1

scripts ×1