2011-09-19 145 views

回答

2

This Works。它只是使用exec自己調用(在這種情況下爲test_script)。但要非常小心,以確保它不會無限運行,只需添加一個條件即可調用exit

#!/usr/bin/env ruby 

if ARGV[0] == "--second" 
    puts "...called again and exiting." 
    exit 
end 

puts "Calling self again..." 
exec "sudo ./test_script --second" 
相關問題