최근 bash를 사용하여 chntpw
으로 Windows 복구 디스크를 자동화하기 시작했습니다. 어떤 chntpw
대화 질문을 듣고 사용자 입력없이 올바른 대답을 입력하기 위해 expect
명령을 사용하는 프로그램을 설정하려고합니다. 어떤 이유로 든 #!/bin/bash
이 아닌 #!/usr/bin/expect
을 사용하도록 bash 스크립트를 설정 한 후 더 많은 표준 터미널 명령을 더 이상 이해할 수 없습니다.간단한 명령이 없습니다. bash (#!/usr/bin/expect)
[email protected]:~/Desktop/projects/breezee$ bash breezee1.sh
터미널 출력은 다음과 같다 :
내가 터미널에이를 입력하여 스크립트를 실행하고있어에서
#!/usr/bin/expect
clear
echo "BREEZEE 1.0"
echo "Welcome to BREEZEE"
fdisk -l
#list partitions
echo -n "[Select] /dev/:"
#ask user to choose primary windows partition
read sda
clear
echo /dev/$sda selected
umount /dev/$sda
sudo ntfsfix /dev/$sda
sudo mount -t ntfs-3g -o remove_hiberfile /dev/$sda /mnt/
cd /mnt/Windows/System32/config
clear
chntpw -l SAM #list accounts on windows partition
chntpw -u Administrator SAM
#now supply chntpw with values to run the password clear (this answers the prompts)
expect '> '
send '1\r'
expect '> '
send '2\r'
expect '> '
send '3\r'
expect ': '
send 'y\r'
expect '> '
send 'q\r'
expect ': '
send 'y\r'
clear
echo "Operation Successfull!"
chntpw -l SAM #list accounts on windows partition
: 여기
BREEZEE 1.0
Welcome to BREEZEE
breezee1.sh: line 9: fdisk: command not found
[Select] /dev/:
내 코드입니다 짧음, 표준 bash/terminal 명령을
expect
명령과 함께 사용하려고합니다. 나는이 모든 잘못에 대해 아마 갈거야. 그래서 나는 약 3 일 동안이 문제를 해결해 왔고 멀리 가지 않았다. (
이것은 실제로 많은 의미가 있습니다. bash에 익숙하지 않은 나는 방금'! #/usr/bin/expect'가 예상 된 지원을 포함하는 대안적인 bash 인터프리터라고 생각했습니다. 분명히 나는 틀렸고, 그게 내 혼란의 원인이었습니다. 고마워요! – pattyd
잠깐, 그래서 나는 인터프리터를'! #/bin/bash'로 바꾸었고 여전히'fdisk : command not found' 문제가 발생 했습니까? ** 업데이트 : **'sudo'를 추가하여 수정했습니다. – pattyd
@pattyd : 또한 예를 들어 스크립트를 실행합니다. 'bash breezee1.sh'는 shebang ('#!') 줄에 상관없이 bash 스크립트로 실행합니다. 일반적으로 스크립트를 실행 가능하게 설정해야합니다 (예 :'chmod + x breezee1.sh') 그런 다음'./breezee1.sh'와 같은 명령을 실행합니다 (shebang이 어떻게 동작하는지 제어 할 수 있습니다). –