我正在编写一个使用对话框的脚本文件(sh文件),我已经到了一个点,我只是想在几周内把它放在一边,因为我生气地寻找错误。< / p>
需要注意的脚本部分:
INPUT=/tmp/input.sh.$$ #Just a tmp file used for storing information
FIELDS=/tmp/fields.sh.$$ #Just a tmp file used for storing information
function view_folder_properties() {
dialog --title "Choose a folder to view properties from" --dselect / 23 60 2> $INPUT
location=$(<"${INPUT}")
stat $location > $FIELDS
dialog --title "Viewing permissions" --textbox $FIELDS 23 60
}
问题不在于代码中的前两行,但是当我想执行stat和dialog时,它会返回两行错误,如下所示:
./lab-E.sh: line 232: stat: command not found
./lab-E.sh: line 233: dialog: command not found
我一直在寻找这个问题差不多一两个小时但仍然无法找到任何问题,这就是我寻求帮助的原因。
在我的系统上回显$ PATH变量如下所示:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/ProgramData/Oracle/Java/javapath_target_98747640:/mnt/c/Program Files (x86)/Razer Chroma SDK/bin:/mnt/c/Program Files/Razer Chroma SDK/bin:/mnt/c/Program Files (x86)/Intel/iCLS Client:/mnt/c/Program Files/Intel/iCLS Client:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files (x86)/IVI Foundation/VISA/WinNT/Bin:/mnt/c/Program Files/Intel/WiFi/bin:/mnt/c/Program Files/Common Files/Intel/WirelessCommon:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/GtkSharp/2.12/bin:/mnt/c/Program Files/dotnet:/mnt/c/Users/<USERNAME>/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/<USERNAME>/AppData/Local/GitHubDesktop/bin:/snap/bin
对话框和统计信息路径/ usr / bin位于上面的$ PATH
中root@LAPTOP-UOKAJ438:~# which stat
/usr/bin/stat
root@LAPTOP-UOKAJ438:~# which dialog
/usr/bin/dialog
root@LAPTOP-UOKAJ438:~#
答案 0 :(得分:1)
Function Workdays(Start_Date As Date, End_Date As Date) AS Integer
Dim Temp_Delta As Integer, X As Integer, Y As Integer
Temp_Delta = End_Date - Start_Date
Temp_Delta = 5 * (Temp_Delta \ 7)
X = Weekday(End_Date, vbMonday)
Y = Weekday(Start_Date, vbMonday)
If X > 5 Then X = 5
If Y > 5 Then Y = 5
Temp_Delta = Temp_Delta + X - Y
Workdays = Temp_Delta
End Function
和stat
不是shell内置的,它们是外部程序。如果没有完整路径,则必须在dialog
环境变量中搜索其位置,该变量通常包含其公共位置(分别为$PATH
和/bin
)。
但你在前一行改变了$ PATH。新的$ PATH可能不包含命令所在的目录。
如果您只想要一个变量来存储路径而不是系统路径,请选择一个不同的名称(/usr/bin
就可以了。)