我正在尝试创建一个应用程序,它将找到一个文件并根据用户输入附加它但我遇到了查找部分的问题。
display dialog "Please Enter Password" default answer "Enter Password Here"
set pass to text returned of result
display dialog "Please Enter file to be located. Use *'s for parts unknown" default answer "File Name Here"
set fle to text returned of result
do shell script "find / -name '$fle'" password pass with administrator privileges
那是该部分的代码段,但无论我如何修改它,我都会得到这个
error "find: /dev/fd/9: Bad file descriptor
find: /dev/fd/11: Not a directory
find: /dev/fd/12: Not a directory" number 1
我给变量“fle”的实际输入是Gameover *;与/ dev / fd /(随机数)
无关答案 0 :(得分:0)
虽然需要永远,但请尝试:
display dialog "Please Enter Password" default answer "Enter Password Here"
set pass to text returned of result
display dialog "Please Enter file to be located. Use *'s for parts unknown" default answer "File Name Here"
set fle to text returned of result
set myResults to (do shell script "find / -name " & quoted form of fle & ";" password pass with administrator privileges)
使用mdfind可能会更好。
答案 1 :(得分:0)
谢谢adayzdone!最终和工作脚本是这样的,以防任何其他人需要它。
display dialog "Please Enter Password" default answer "Enter Password Here"
set pass to text returned of result
display dialog "Please enter file to be located. Use *'s for parts unknown" default answer "File Name Here"
set fle to text returned of result
display dialog "Please enter where you would like to look. Leave default answer if unsure." default answer "/"
set loc to text returned of result
set newfile to (do shell script "find " & quoted form of loc & " -name " & quoted form of fle password pass with administrator privileges)
display dialog newfile