×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

求助! 哪位大侠能帮忙把这段shell script 改写成perl on windows? 多谢多谢!

#!/bin/sh

# time between each screen
refresh_timeout=5

# location of screens
home_dir=screens

# temp runtime file for tracking current screen
cntfile=/var/cnt

# if no cntfile (e.g. when starting) default to #1
if [ -f $cntfile ]; then
cnt=`cat $cntfile`
else
cnt=1
fi

# wrap when we run out
if [ ! -f ../$home_dir/$cnt.jpg ]; then
cnt=1
fi

# html stuff
echo "Content-type: text/html"
echo ""
echo "<HTML>"
echo "<HEAD>"
echo "<TITLE>Slideshow</TITLE>"
echo "<meta http-equiv=\"Refresh\" Content=\"$refresh_timeout; URL=/cgi-bin/display.sh\">"
echo "</HEAD>"
echo "<BODY bgcolor=\"#ffffff\" text=\"#ffffff\">"
echo "<a href=\"/cgi-bin/print.sh\"><img align=\"left\" img border=\"0\" img src=\"/$home_dir/$cnt.jpg\"</a>"
echo "</BODY></HTML>"

# point to next screen
let cnt="$cnt+1"
echo $cnt > $cntfile
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 求助! 哪位大侠能帮忙把这段shell script 改写成perl on windows? 多谢多谢!
    #!/bin/sh

    # time between each screen
    refresh_timeout=5

    # location of screens
    home_dir=screens

    # temp runtime file for tracking current screen
    cntfile=/var/cnt

    # if no cntfile (e.g. when starting) default to #1
    if [ -f $cntfile ]; then
    cnt=`cat $cntfile`
    else
    cnt=1
    fi

    # wrap when we run out
    if [ ! -f ../$home_dir/$cnt.jpg ]; then
    cnt=1
    fi

    # html stuff
    echo "Content-type: text/html"
    echo ""
    echo "<HTML>"
    echo "<HEAD>"
    echo "<TITLE>Slideshow</TITLE>"
    echo "<meta http-equiv=\"Refresh\" Content=\"$refresh_timeout; URL=/cgi-bin/display.sh\">"
    echo "</HEAD>"
    echo "<BODY bgcolor=\"#ffffff\" text=\"#ffffff\">"
    echo "<a href=\"/cgi-bin/print.sh\"><img align=\"left\" img border=\"0\" img src=\"/$home_dir/$cnt.jpg\"</a>"
    echo "</BODY></HTML>"

    # point to next screen
    let cnt="$cnt+1"
    echo $cnt > $cntfile
    • Dame, So easy perl and shell script you need other help? What are you doing ??? see my convert ;)
      $home_dir = 'screens';
      $filename = '/var/cnt';
      if (-e "$filename")
      {
      open(FH, $filename);
      $cnt = <FH>;
      chomp( $cnt );
      }
      else
      {
      $cnt =1;
      }

      close(FH);
      open(FH2, ">$filename");
      print FH2 $cnt+1;
      close(FH2);
      print <<NOHAIRMONK
      Content-type: text/html

      <HTML>
      <HEAD>
      <TITLE>Slideshow</TITLE>
      <meta http-equiv=Refresh Content=5
      </HEAD>
      <BODY bgcolor=#ffffff text=#ffffff>
      <a href=/cgi-bin/print.sh><img align=left img border=0 img src=/$home_dir/$cnt.jpg</a>
      </BODY></HTML>
      NOHAIRMONK