簡體   English   中英

語法外殼腳本? “單詞意外出現在” getopts

[英]Syntax shell scripting? “word unexpected in” getopts

大家晚上好,我們期待在Ubuntu 8.04上執行Shell腳本,但是它返回一個特殊錯誤:

line 14: Word unexpected (expecting "in")

因此,這是腳本的預覽:

#!/bin/sh
#Declaration of shell parameters
A3REP=""
A3FILE=""
A3HELP=""
A3PORT="80"
A3PORTTC="80"
A3IP400=""
A3USER=""
A3PWD=""
A3TASK=""
while getopts d:f:h:p:i:u:w:t:n: option
do 
  case $option in
    d)
    A3REP="$OPTARG"
    ;;
    f)  
    A3FILE="$OPTARG"
        ;;
    p)  
    A3PORT="$OPTARG"
        ;;
    t)  
    A3PORTTC="$OPTARG"
        ;;
    i)  
    A3IP400="$OPTARG"
        ;;
    u)  
    A3USER="$OPTARG"
        ;;
    w)  
    A3PWD="$OPTARG"
        ;;
    n)  
    A3TASK="$OPTARG"
        ;;
    h)
    A3HELP="aide"
    ;;
  esac
done

解決的問題:該腳本在dos中:

在d2u.sh中插入以下行:

#!/bin/bash
cat $1|tr -d '\015'

現在執行:

chmod +x d2u.sh

現在腳本可以運行了。

嘗試使用以下命令鍵入以下腳本:

sh d2u.sh filename.sh > filename2.sh

而且該腳本已不再使用。

謝謝大家! :)

也許行尾有問題,請嘗試

d2u FILE

參考

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM