我有一个plist文件,应该在启动时启动shell脚本。
create table Member_ID(
Member_ID int not null,
Title varchar(4) not null,
Forename varchar(30) not null,
Surname varchar(30) not null,
DOB date not null,
`Address 1` varchar(30) not null,
`Address 2` varchar(30) not null,
Postcode varchar(8) not null,
MobileNo char (11) not null,
Email varchar (30) not null,
Gender char (1) not null,
Medical varchar (30) not null,
Joining_Date date not null,
Paid varchar(4) not null,
Membership_Type char(1) not null,
Staff_Initials char (2) not null,
Primary key (Member_ID)
);
create table class(
Class_Name varchar (30) not null,
ClassDayofWeek date not null,
`Class_Time select get` date not null,
Class_Duration char(4) not null,
Studio_ID char (4) not null,
Instructor_ID int not null
);
create table class_list(
Class_ID varchar(30) not null,
Member_ID int not null,
Date_Booked date not null
);
create table Instructor(
Instructor_ID int not null,
InsFirstName varchar (30) not null,
InsSurname varchar (30) not null,
InsContactNo char (11) not null
);
create table Equipment(
Equip_ID int not null,
Supplier_ID int not null,
Studio_ID int not null,
Equip_Name varchar (30)
);
create table supplier(
Supplier_ID int not null,
Supplier_Name varchar (30) not null,
SupplierContactNo char (11) not null,
Supplier_Email varchar (30) not null
);
create table Equipment_Maintanence(
Maintenence_ID int not null,
EquipID int not null,
Main_date date not null,
Maint_ID int not null,
Eng_Name varchar(30),
Fault_Desc varchar (200),
Maint_Type varchar (7)
);
我已将plist文件保存为<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.app.localclient</string>
<key>Program</key>
<string>~/Documents/Local_client/Server.sh</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
,并测试了可正常工作的shell脚本。当我尝试使用com.app.localclient.plist
加载脚本时,它会加载plist但不会启动shell脚本。我还将程序参数launchctl load com.app.localclient.plist
更改为~
,但没有成功。有没有办法让plist启动shell脚本,这可以在不知道脚本保存位置的用户名的情况下完成(所以在路径中使用〜)。
答案 0 :(得分:0)
也许尝试运行一个shell,因为它会知道你的$ HOME:
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>-c</string>
<string>"$HOME/Documents/Local_client/Server.sh"</string>
</array>
为了调试这个,请尝试:
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>-c</string>
<string>"echo hi > /tmp/DEBUG.txt"</string>
</array>
然后看看/tmp/DEBUG.txt
是否存在。如果可行,请尝试制作最后一个字符串
"/usr/bin/whoami > /tmp/DEBUG.txt"
然后查看/tmp/DEBUG.txt