開発環境
- OS X Lion - Apple(OS)
- BBEdit - Bare Bones Software, Inc., Emacs(Text Editor)
- プログラミング言語: Perl
『初めてのPerl 第6版』(Randal L. Schwartz, Tom Phoenix, brian d foy 共著、近藤 嘉雪 訳、オライリー・ジャパン、2012年、ISBN978-4-87311-567-2)の16章(プロセス管理)の16.9(練習問題)1を解いてみる。
その他参考書籍
1.
コード(BBEdit)
sample.pl
#!/usr/bin/env perl use strict; use warnings; use 5.016; use utf8; binmode STDOUT, ':utf8'; binmode STDIN, ':utf8'; binmode STDERR, ':utf8'; chdir "/" or die "can't chdir to root director: $!"; exec "ls", "-l" or die $!;
入出力結果(Terminal)
$ ./sample.pl total 30461 drwxrwxr-x+ 64 root admin 2176 8 26 11:04 Applications drwxrwxr-x@ 19 root admin 646 8 6 2011 Developer-3.2.6 drwxr-xr-x+ 69 root wheel 2346 10 14 2012 Library drwxr-xr-x@ 2 root wheel 68 8 17 2011 Network drwxr-xr-x+ 4 root wheel 136 3 16 19:28 System drwxr-xr-x 5 root admin 170 10 16 2011 Users drwxrwxrwt@ 8 root admin 272 8 28 09:18 Volumes drwxr-xr-x@ 39 root wheel 1326 9 20 2012 bin drwxrwxr-t@ 2 root admin 68 8 17 2011 cores dr-xr-xr-x 3 root wheel 4358 8 25 13:17 dev lrwxr-xr-x@ 1 root wheel 11 10 16 2011 etc -> private/etc dr-xr-xr-x 2 root wheel 1 8 26 06:48 home drwxrwxrwt 3 root wheel 102 7 1 2012 lost+found -rw-r--r--@ 1 root wheel 15572704 8 24 2012 mach_kernel dr-xr-xr-x 2 root wheel 1 8 26 06:48 net drwxr-xr-x 3 root admin 102 9 5 2011 opt drwxr-xr-x@ 6 root wheel 204 10 16 2011 private drwxr-xr-x@ 62 root wheel 2108 9 20 2012 sbin lrwxr-xr-x@ 1 root wheel 11 10 16 2011 tmp -> private/tmp drwxr-xr-x@ 15 root wheel 510 5 10 2012 usr lrwxr-xr-x@ 1 root wheel 11 10 16 2011 var -> private/var lrwxr-xr-x 1 root admin 60 3 23 2010 ユーザーズガイドと情報 -> /Library/Documentation/User Guides and Information.localized $
ちなみにpython3.3の場合。
コード(BBEdit)
sample.py
#!/usr/bin/env python3.3 ## Copyright (C) 2013 by kamimura #-*- coding: utf-8 -*- import os os.chdir("/") os.system("ls -l")
入出力結果(Terminal)
$ ./sample.py total 30461 drwxrwxr-x+ 64 root admin 2176 8 26 11:04 Applications drwxrwxr-x@ 19 root admin 646 8 6 2011 Developer-3.2.6 drwxr-xr-x+ 69 root wheel 2346 10 14 2012 Library drwxr-xr-x@ 2 root wheel 68 8 17 2011 Network drwxr-xr-x+ 4 root wheel 136 3 16 19:28 System drwxr-xr-x 5 root admin 170 10 16 2011 Users drwxrwxrwt@ 8 root admin 272 8 28 09:18 Volumes drwxr-xr-x@ 39 root wheel 1326 9 20 2012 bin drwxrwxr-t@ 2 root admin 68 8 17 2011 cores dr-xr-xr-x 3 root wheel 4358 8 25 13:17 dev lrwxr-xr-x@ 1 root wheel 11 10 16 2011 etc -> private/etc dr-xr-xr-x 2 root wheel 1 8 26 06:48 home drwxrwxrwt 3 root wheel 102 7 1 2012 lost+found -rw-r--r--@ 1 root wheel 15572704 8 24 2012 mach_kernel dr-xr-xr-x 2 root wheel 1 8 26 06:48 net drwxr-xr-x 3 root admin 102 9 5 2011 opt drwxr-xr-x@ 6 root wheel 204 10 16 2011 private drwxr-xr-x@ 62 root wheel 2108 9 20 2012 sbin lrwxr-xr-x@ 1 root wheel 11 10 16 2011 tmp -> private/tmp drwxr-xr-x@ 15 root wheel 510 5 10 2012 usr lrwxr-xr-x@ 1 root wheel 11 10 16 2011 var -> private/var lrwxr-xr-x 1 root admin 60 3 23 2010 ユーザーズガイドと情報 -> /Library/Documentation/User Guides and Information.localized $
0 コメント:
コメントを投稿