その先にあるもの…

expect에 변수값 set 본문

Linux_Raspberry

expect에 변수값 set

specialJ 2021. 3. 17. 17:23

kldp.org/node/3966

 

expect로 만든 스크립트에서 변수 값을 읽어 들이려면? | KLDP

글쓴이: 익명 사용자 / 작성시간: 일, 2002/09/29 - 5:24오후 저는 아래와 같은 스크립트를 만들었습니다. --------------zz------------------------- #!/usr/bin/expect spawn bash -c "su - aaa" expect -re "Password" sleep 0.2 send "

kldp.org

 

#!/usr/bin/expect
#!/bin/bash  <<== 주석으로 인식

 

expect에서는 다른 프로그램들과 비슷하게 argv와 argc에
파라메터를 넣음

-- TCL 이 이렇고, expect는 TCL의 확장이니 당연히 동일하게 쓰임

 

argv( 인자값들 )와 argc(인자 갯수) 를 조작

 

#!/usr/local/bin/expect

 

if {$argc < 2} {
puts "usage progname id pwd"
exit
}

set id [lindex $argv 0]
set pwd [lindex $argv 1]

 

puts "program name $argv0"
puts "id $id"
puts "pwd $pwd"

 

 

'Linux_Raspberry' 카테고리의 다른 글

sed 파일들 안에 있는 글자 바꾸기  (0) 2021.03.17
bash에서 expect 사용  (0) 2021.03.17
리눅스 awk  (0) 2021.03.17
라즈베리파이4 ubuntu20.04 conda 설치  (0) 2021.03.16
expect, bash, "missing close bracket"  (0) 2021.03.15
Comments