명령 실행 예제 코드 (os.execute)
os.execute는 Shell에 의존하며, 탈옥된 iOS 환경의 Shell은 Bash 또는 Zsh일 수 있습니다.
TrollStore 버전의 XXTouch는 os.execute를 지원하지 않습니다.
가능하면 os.execute를 사용하지 않는 것이 좋습니다.
기기 재시작
-- os.execute('reboot')
-- 다음 호출을 대신 사용하는 것이 좋습니다
sys.reboot()
기기 리스프링
-- os.execute('killall -9 SpringBoard;killall -9 backboardd')
-- 다음 호출을 대신 사용하는 것이 좋습니다
sys.killall(9, 'SpringBoard', 'backboardd')
아이콘 캐시 다시 만들기
-- os.execute('su mobile -c uicache')
-- 다음 호출을 대신 사용하는 것이 좋습니다
clear.caches()
스크립트 로그의 심볼릭 링크를 스크립트 디렉터리에 생성
-- os.execute('ln -s /private/var/mobile/Media/1ferver/log/sys.log /private/var/mobile/Media/1ferver/lua/scripts/脚本日志.txt')
-- 다음 호출을 대신 사용하는 것이 좋습니다
lfs.link('/private/var/mobile/Media/1ferver/log/sys.log', '/private/var/mobile/Media/1ferver/lua/scripts/脚本日志.txt', true)
자주 사용하는 작업 래핑
--[[
아래 래핑은 더 이상 권장하지 않습니다. XXTouch에 내장된 file 모듈 함수를 대신 사용하십시오
--]]
local function sh_escape(path) -- XXTouch에서 만든 함수이며 XXTouch의 별도 허가 없이 상업적 용도로 사용할 수 있습니다
path = string.gsub(path, "([ \\()<>'\"`#&*;?~$|])", "\\%1")
return path
end
function fdelete(path) -- 파일 또는 디렉터리 삭제(하위 항목 재귀 삭제)
assert(type(path)=="string" and path~="", 'fremove 参数异常')
-- os.execute('rm -rf '..sh_escape(path))
-- 다음 호출을 대신 사용하는 것이 좋습니다
file.remove(path)
end
function frename(from, to) -- 파일 또는 디렉터리 이름 변경(이동)
assert(type(from)=="string" and from~="", 'frename 参数 1 异常')
assert(type(to)=="string" and to~="", 'frename 参数 2 异常')
-- os.execute('mv -f '..sh_escape(from).." "..sh_escape(to))
-- 다음 호출을 대신 사용하는 것이 좋습니다
file.move(from, to, 'mo')
end
function fcopy(from, to) -- 파일 또는 디렉터리 복사(하위 항목 재귀 복사)
assert(type(from)=="string" and from~="", 'fcopy 参数 1 异常')
assert(type(to)=="string" and to~="", 'fcopy 参数 2 异常')
-- os.execute('cp -rf '..sh_escape(from).." "..sh_escape(to))
-- 다음 호출을 대신 사용하는 것이 좋습니다
file.copy(from, to, 'mo')
end
function mkdir(path) -- 디렉터리 생성(하위 디렉터리 재귀 생성)
assert(type(path)=="string" and path~="", 'mkdir 参数异常')
-- os.execute('mkdir -p '..sh_escape(path))
-- 다음 호출을 대신 사용하는 것이 좋습니다
file.mkdir_p(path)
end
-- 위는 래핑된 함수입니다. 스크립트 맨 앞에 복사하여 사용할 수 있습니다.
-- 아래는 호출 예제이며 복사할 필요가 없습니다.
-- /var/mobile/1.png 삭제
fdelete("/var/mobile/1.png")
-- /var/mobile/2.png의 이름을 /var/mobile/1.png로 변경
frename("/var/mobile/2.png", "/var/mobile/1.png")
-- /var/mobile/1.png를 /var/mobile/Media/1ferver/res/3.png로 이동
frename("/var/mobile/1.png", "/var/mobile/Media/1ferver/res/3.png")
-- /var/mobile/1.png를 /var/mobile/Media/1ferver/res/4.png로 복사
fcopy("/var/mobile/1.png", "/var/mobile/Media/1ferver/res/4.png")
-- /var/mobile/1/2/3/4/ 디렉터리 생성
mkdir("/var/mobile/1/2/3/4")