簡體   English   中英

捕獲R中At命令的ID

[英]Capture ID of At Command in R

問題:我想捕獲at命令作業的ID

這是執行at命令的普通代碼

> system(command="echo touch my_path/test_file.in | at 05:26 AM")

這是輸出

job 984 at 2015-12-11 05:26


由於我想捕獲at命令的ID,因此我添加了system()函數的“ intern”參數並將ID保存到變量中

> id<-system(command="echo touch my_path/test_file.in | at 05:26 AM", intern=TRUE)


仍然沒有捕獲輸出,所以我嘗試了system2()函數

> id<-system2(command="echo touch my_path/test_file.in | at 05:26 AM", stdout=TRUE, stderr=TRUE)


還是行不通。 有人可以幫我弄這個嗎?

system2()引用該命令,因此您可能想使用類似

id <- system2(
      "sh",
      c("-c","echo touch my_path/test_file.in | at 05:26 AM"),
      stdout=TRUE, stderr=TRUE
     )

另外,您可以堅持使用system()stderr

id <- system("echo touch my_path/test_file.in | at 05:16 AM 2>&1", int=T)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM