2013年1月12日土曜日

開発環境

『初めてのPerl 第6版』(Randal L. Schwartz, Tom Phoenix, brian d foy 共著、近藤 嘉雪 訳、オライリー・ジャパン、2012年、ISBN978-4-87311-567-2) の15章(プロセス管理)、15.6(練習問題)5を解いてみる。

その他参考書籍

1.

コード(BBEdit)

sample.pl

#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use 5.016;
binmode STDOUT, ':utf8';
binmode STDIN, ':utf8';

chdir "/" or die "can't chdir to root directory: $!";
exec 'ls', '-l' or die "can't exec 'ls -l': $!";

入出力結果(Terminal)

$ ./sample.pl
total 30461
drwxrwxr-x+ 65 root  admin      2210  1  8 10:04 Applications
drwxrwxr-x@ 19 root  admin       646  8  6  2011 Developer-3.2.6
drwxr-xr-x+ 69 root  wheel      2346 10 14 02:04 Library
drwxr-xr-x@  2 root  wheel        68  8 17  2011 Network
drwxr-xr-x+  4 root  wheel       136  9 20 08:39 System
drwxr-xr-x   5 root  admin       170 10 16  2011 Users
drwxrwxrwt@  7 root  admin       238  1 12 10:29 Volumes
drwxr-xr-x@ 39 root  wheel      1326  9 20 08:31 bin
drwxrwxr-t@  2 root  admin        68  8 17  2011 cores
dr-xr-xr-x   3 root  wheel      4447  1  8 02:03 dev
lrwxr-xr-x@  1 root  wheel        11 10 16  2011 etc -> private/etc
dr-xr-xr-x   2 root  wheel         1  1 11 13:37 home
drwxrwxrwt   3 root  wheel       102  7  1  2012 lost+found
-rw-r--r--@  1 root  wheel  15572704  8 24 08:27 mach_kernel
dr-xr-xr-x   2 root  wheel         1  1 11 13:37 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 08:31 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
$

ちなみにpythonの場合。

sample.py

コード(BBEdit)

#!/usr/bin/env python3.3
#-*- coding: utf-8 -*-

import os

os.chdir("/")
os.system('ls -l')

入出力結果(Terminal)

$ ./sample.py
total 30461
drwxrwxr-x+ 65 root  admin      2210  1  8 10:04 Applications
drwxrwxr-x@ 19 root  admin       646  8  6  2011 Developer-3.2.6
drwxr-xr-x+ 69 root  wheel      2346 10 14 02:04 Library
drwxr-xr-x@  2 root  wheel        68  8 17  2011 Network
drwxr-xr-x+  4 root  wheel       136  9 20 08:39 System
drwxr-xr-x   5 root  admin       170 10 16  2011 Users
drwxrwxrwt@  5 root  admin       170  1 12 10:58 Volumes
drwxr-xr-x@ 39 root  wheel      1326  9 20 08:31 bin
drwxrwxr-t@  2 root  admin        68  8 17  2011 cores
dr-xr-xr-x   3 root  wheel      4304  1  8 02:03 dev
lrwxr-xr-x@  1 root  wheel        11 10 16  2011 etc -> private/etc
dr-xr-xr-x   2 root  wheel         1  1 12 11:13 home
drwxrwxrwt   3 root  wheel       102  7  1  2012 lost+found
-rw-r--r--@  1 root  wheel  15572704  8 24 08:27 mach_kernel
dr-xr-xr-x   2 root  wheel         1  1 12 11:13 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 08:31 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 コメント:

コメントを投稿