68user's page 掲示板

Prev< No. 4896〜4909> Next  [最新発言に戻る] [過去ログ一覧]
No. 4896 # 68user 2008/03/27 (木) 11:44:00
>>4895 べた
perl コンパイルの際の Configure 時に設定する方法があります。

それが無理なら
    #!/bin/sh
    PERL_BADLANG=0 /foo/bar/baz.pl
と wrapper を作るか、env コマンドで
    #!/usr/bin/env PERL_BADLANG=0 /usr/local/bin/perl
とする手もあります。

No. 4897 # べた 2008/03/27 (木) 12:55:00
>>4896 68user
ありがとうございます。

#!/usr/bin/env PERL_BADLANG=0 /usr/local/bin/perl
#

とperlのスクリプト内に記述して、実行したのですが、
処理がとまったというか、何も応答が返ってきません。

No. 4898 # 68user 2008/03/27 (木) 23:05:24
>>4897 べた
なるほど FreeBSD 5.2.1-RELEASE では動きますが、Linux では確かに
無限ループしてますねぇ。

> #!/usr/bin/env PERL_BADLANG=0 /usr/local/bin/perl
これは FreeBSD 5.2.1-RELEASE では
    /usr/bin/env PERL_BADLANG=0 /usr/local/bin/perl ./hoge
と解釈されますが、Linux や Solaris では
    /usr/bin/env "PERL_BADLANG=0 /usr/local/bin/perl" ./hoge
となるため
    PERL_BADLANG="0 /usr/local/bin/perl"
という環境変数が設定されつつ
    /usr/bin/env ./a
が実行されるものの、./hoge のシェバング行にはまた同じ内容が
書かれているため、永遠に
    execve("./a");
が実行されるということですね。

参考:
    http://x68000.q-e-d.net/~68user/unix/pickup?%A5%B7%A5%A7%A5%D0%A5%F3%A5%B0
    の Tips.2

というわけで env コマンドを使うやり方は移植性がありませんでしたが、
    #!/bin/sh
    PERL_BADLANG=0 /foo/bar/baz.pl
なら動くと思います。Linux では動きました。

No. 4899 # べた 2008/03/28 (金) 12:53:23
>> 4898

> #!/bin/sh
> PERL_BADLANG=0 /foo/bar/baz.pl
>なら動くと思います。Linux では動きました。
で動きました。

色々とありがとうございました。

No. 4900 # 68user 2008/04/02 (水) 19:10:27
さきほどお問い合わせページよりご指摘いただきました、ジャンル一覧リンク切れの件、
修正しました。ご指摘ありがとうございます>連絡いただいた方

No. 4901 # 68user 2008/04/18 (金) 13:53:44
2年半ぶりの人材募集です。
http://x68000.q-e-d.net/~68user/tmp/job2.html

No. 4902 # TKC 2008/05/02 (金) 14:09:57
こんにちわ。
findコマンドについて教えてください。

■要件
カレントディレクトリに存在する31日以前のファイル&ディレクトリの削除を実施したい

■コマンド
find ./ -mtime +31 -exec ls {} \; -exec rm -r {} \; >> test.log

■結果
./20070101.trc
find: ./aaa: No such file or directory

■質問1
カレントディレクトリに削除対象となる日付のファイル20070101.trcとディレクトリaaaを配置しています。
削除ファイルの一覧を取得したいため-exec ls {} \;を使用したのですが、
ログには./20070101.trcしか記載がありません。
ディレクトリも表示させるには何かオプションが必要なのでしょうか?

■質問2
実行結果としては削除は行われているのですが戻り値がエラーとなっています。
find: ./aaa: No such file or directoryの部分を指していると思うのですが、
削除後にfindしているように見受けられますがこのエラーの出力原因はなんでしょうか?

1と2の解決方法がありましたら教えてください。
宜しくお願いします。

No. 4903 # 68user 2008/05/02 (金) 16:00:22
>>4902 TKC
まず、-exec の代わりに -ok を使って何が実行されているか確認しましょう。

> ディレクトリも表示させるには何かオプションが必要なのでしょうか?
./aaa/ の中身が空ではないですか? 空であれば ls ./aaa しても何も
表示されないと思います。

> 削除後にfindしているように見受けられますがこのエラーの出力原因は
> なんでしょうか?
find はディレクトリを下降してファイルを探しますが、おそらく
ディレクトリを削除した後にそのディレクトリに下りようとしている
のではないでしょうか。-prune を組み合わせれば下りないように
できるかもしれません (試していません)。

No. 4904 # TKC 2008/05/02 (金) 16:38:38
>>4903 68userさん
-okを使用して確認しました。
ご察しの通り./aaa配下が空のため< ls ... ./aaa >となり
結果的にログに./aaaが出力されていないことがわかりました。

findのエラー原因はやはり削除後に配下に移動しているものと思われます。
rmにデータが渡る前に-pruneを使い解消されました。

最終的には下記で行いたい処理ができました。
find ./ -mtime +31 -prune -exec ls -d {} \; -exec rm -r {} \;

どうもありがとうございました。

No. 4906 # hoge 2008/05/19 (月) 00:21:11
いつもこちらにはお世話になってます。

flexについての指摘です。
http://x68000.q-e-d.net/~68user/unix/pickup?flex

GNUでは作成・配布してないようです。
http://ftp.gnu.org/gnu/flex/flex.README

No. 4907 # 68user 2008/05/19 (月) 23:44:38
>>4906 hoge
> GNUでは作成・配布してないようです。
そうなんですか。知りませんでした。

ftp://ftp.gnu.org/non-gnu/flex/flex.README
      Flex is a free implementation of the well-known Lex program for lexical
      analysis. Since it is not (and never was) a GNU package, we don't
      distribute it here. Please see http://flex.sourceforge.net for the
      latest release and information.


flex-2.5.4 (1997年リリース) の README
      Note that flex is distributed under a copyright very similar to that of
      BSD Unix, and not under the GNU General Public License (GPL), except for
      the "configure" script, which is covered by the GPL.

などを見るに、確かに flex が GNU ではないようですね。

しかしこの書籍
    http://www.ascii.co.jp/books/books/detail/4-7561-3097-6.shtml
        Flex入門
        シリーズ:GNUシリーズ
        GNUのツールの1つとして広く使用されているGNUのLexical Scanner Generatorで
        あるFlexの解説書。豊富な例とともに機能を詳細解説
はどうなんですかね。

wikipedia(en) には
    http://en.wikipedia.org/wiki/Flex_lexical_analyser
        Flex is a non-GNU project, but the GNU project developed the manual for Flex.
とありますが、「GNU が作った flex のマニュアル」の翻訳が上記の「Flex 入門」
だったりするんでしょうか。

No. 4908 # 68user 2008/05/19 (月) 23:57:23
>>4907 68user
うーん、やはり 2.5.3 以前は GNU だったのだろうか。

http://cocoa.2ch.net/unix/kako/970/970914036.html より
----- ここから -----
Flex はそもそも non-gnuに移動になって、
下の Flex 2.5.4の COPYING みたいなことになっている。
-=-=-=-=-
Flex carries the copyright used for BSD software, slightly modified
because it originated at the Lawrence Berkeley (not Livermore!) Laboratory,
which operates under a contract with the Department of Energy:

Copyright (c) 1990 The Regents of the University of California.
All rights reserved.

This code is derived from software contributed to Berkeley by
Vern Paxson.

The United States Government has rights in this work pursuant
to contract no. DE-AC03-76SF00098 between the United States
Department of Energy and the University of California.

Redistribution and use in source and binary forms with or without
modification are permitted provided that: (1) source distributions
retain this entire copyright notice and comment, and (2)
distributions including binaries display the following
acknowledgement: ``This product includes software developed by the
University of California, Berkeley and its contributors'' in the
documentation or other materials provided with the distribution and
in all advertising materials mentioning features or use of this
software. Neither the name of the University nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.

This basically says "do whatever you please with this software except
remove this notice or take advantage of the University's (or the flex
authors') name".

Note that the "flex.skl" scanner skeleton carries no copyright notice.
You are free to do whatever you please with scanners generated using flex;
for them, you are not even bound by the above copyright.
----- ここまで -----

「non-gnu に移動」という記述はいろんなところにあるが、それを根拠に
「以前は GNU だった」と言いきれない。古い tarball も見つからないし…。

No. 4909 # 68user 2008/05/24 (土) 14:05:02
>>4908 68user
> うーん、やはり 2.5.3 以前は GNU だったのだろうか。
flex-2.5.2/COPYING を確認しましたが、
>> 下の Flex 2.5.4の COPYING みたいなことになっている。
とほぼ同じでした。よって、以前は flex は GNU であったが、
ある時点から GNU でなくなった、などという事実はないようです。

Prev< No. 4896〜4909> Next  [最新発言に戻る] [過去ログ一覧]