#navi(../)
* ファイルのパーミッション変更方法 [#w4e68ccd]

FileUtils.chmodを利用するとファイルのパーミッションを変更することができます。~
''require "fileutils"''が必要になります。

#contents
#htmlinsertpcsp(ll-top.html,ll-sp.html)

* パーミッション変更のサンプルソース [#q140b538]
#ref(file_chmod.rb)
 require "fileutils"
 
 f = File.open("hello.sh", "w")
 f.puts("#!/bin/bash")
 f.puts("echo Hello world!")
 f.close
 FileUtils.chmod(0755, "hello.sh")

** 実行結果 [#f4c69b09]
 $ ruby file_chmod.rb 
 $ ls -l hello.sh 
 -rwxr-xr-x  1 sakura  staff  30  2 11 21:42 hello.sh
 $ ./hello.sh 
 Hello world!

#htmlinsertpcsp(ll-btm.html,ll-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS