
원격 컴퓨터에 로그인하고 거기에서 일부 스크립트를 실행하는 예상 스크립트를 작성합니다. 그러나 다음 사항도 확인해야 합니다.
디렉토리인지 확인
/var/cti/adm/APP exists
아래에 APP가 존재하지 않는 경우아담그런 다음 이 디렉토리를 생성하고 이 디렉토리에 소유권을 추가해야 합니다( chown 시스템으로).
예상 스크립트에 디렉터리가 있는지 확인하는 방법과 이 디렉터리를 만들 필요가 없는 경우 조언을 부탁드립니다.
내 기대 스크립트의 일부 예
#!/usr/bin/expect -f
set multiPrompt {[#>$]}
send "ssh $LOGIN3@$IP\r"
sleep 0.5
expect {
word: {send $PASS\r ; exp_continue }
expect -re $multiPrompt
}
예를 들어 bash로 어떻게 할 수 있는지
[[ ! -d /.../..../... ]] && mkdir xxxxx
답변1
set dirname /var/cti/adm/APP
if {[file exist $dirname]} {
# check that it's a directory
if {! [file isdirectory $dirname]} {
puts "$dirname exists, but it's a file"
}
} else {
file mkdir $dirname
}
또는
if {[catch {file mkdir $dirname} err opts] != 0} {
puts $err
}