Ruby/サンプル/ファイルのパーミッションの変更方法
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* ファイルのパーミッション変更方法 [#w4e68ccd]
FileUtils.chmodを利用するとファイルのパーミッションを変更...
''require "fileutils"''が必要になります。
#contents
//#htmlinsert(ll_ads_top.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!
//#htmlinsert(ll_ads_btm.html)
終了行:
#navi(../)
* ファイルのパーミッション変更方法 [#w4e68ccd]
FileUtils.chmodを利用するとファイルのパーミッションを変更...
''require "fileutils"''が必要になります。
#contents
//#htmlinsert(ll_ads_top.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!
//#htmlinsert(ll_ads_btm.html)
ページ名: