ssh 인바운드 연결에서 3 개의 변수를 사용하는 스크립트를 작성합니다. ID A 이름 스위치 포트 번호명령에 대해 변수를 잘못 입력했습니다.
모두 처리 할 때까지 지느러미입니다. 그리고 저에게 이상한 오류 출력이 나옵니다.
./installations.sh: line 11: ID_1=c8:2a:14:25:b7:f8: command not found
./installations.sh: line 12: Name_1=Jonass-MBP: command not found
./installations.sh: line 14: installationID_2=00:1f:d0:db:b7:48: command not found
./installations.sh: line 15: installationMame_2=JonasKirkPeders: command not found
No attached system on port
No attached system on port
테스트 용으로 PC를 연결 했으므로 원격 스크립트에서 올바른 데이터가 전송되고 있음을 알 수 있습니다. 그러나 왜이 경우 변수가 설정 변수가 아닌 명령으로 잘못 취급됩니까?
echo $1 $2 $3 >> test.log
ID=$1
NAME=$2
LANPORT=$3
if [ -z $1 ] || [ -z $2 ]; then
echo "No attached system on port $LANPORT"
else
case $LANPORT in
1) installationID$LANPORT=$ID
installationName_${LANPORT}=$NAME
;;
2) installationID_$LANPORT=$ID
installationName_${LANPORT}=$NAME
;;
3) installationID_$LANPORT=$ID
installationName_${LANPORT}=$NAME
;;
4) installationID_$LANPORT=$ID
installationName_${LANPORT}=$NAME
;;
*) echo "ERROR - NO such port!! ${LANPORT}" >> test.log
;;
esac
echo "LAN $LANPORT - $installationID_$LANPORT" >> test.log
fi
나는 동적 변수 사용 declare
를 만들려면 아이디어
'이름 _ $ {LANPORT가}'잘못된 것입니다. 마찬가지로 몇 가지 과제가 잘못되었습니다. – devnull
l-value error from C : D 정확히는 아니지만 bash 당신이 할 수있는 일은 파일에서 이들을 반향하고 그 파일을 소트 할 수 있습니다 :) 그렇지 않으면 "lvalue required"를 제거 할 수 없습니다. – PradyJord