Article View: ch.comp.os.linux
Article #12427Re: Pruefen von symbolische links
From: Roberto Nibali
Date: Thu, 05 Jul 2001 09:36
Date: Thu, 05 Jul 2001 09:36
77 lines
3979 bytes
3979 bytes
Hi Christian, > Leider gibt file mir immer den gleichen rueckgabewert :( Ich muss wohl auf Drogen sein. Sorry fuer meine dumme Anwort. Das funktioniert gerade mal auf meinem System so, wie ich es will. Meine SunOS 5.6 node macht folgendes: ratz@cat:~/test > ls -al total 6 drwxr-xr-x 2 ratz users 512 Jul 5 11:16 . drwxr-xr-x 10 ratz users 512 Jul 5 11:13 .. lrwxrwxrwx 1 ratz users 12 Jul 5 11:14 nat a lie -> shit happens -rw-r--r-- 1 ratz users 0 Jul 5 11:16 shit happens ratz@cat:~/test > \rm -f ./shit\ happens ratz@cat:~/test > ls -al total 6 drwxr-xr-x 2 ratz users 512 Jul 5 11:19 . drwxr-xr-x 10 ratz users 512 Jul 5 11:13 .. lrwxrwxrwx 1 ratz users 12 Jul 5 11:14 nat a lie -> shit happens ratz@cat:~/test > file nat\ a\ lie nat a lie: symbolic link to shit happens ratz@cat:~/test > Aber ich habe unten noch einen Vorschlag, wie man es machen koennte. > natalie@natalie:/h/natalie> echo $? > 0 Hmm, also, wenn file so implementiert ist, wie es sollte [stat(2)], dann muesste es -1 oder 255 returnieren, gemaess stat(2). Das file Kommando auf HP-UX scheint diesen returnvalue zu ignorieren. Das ist denkbar schade. > natalie@natalie:/h/natalie> ls -al foo > lrwxrwxr-x 1 natalie users 3 Jul 5 10:57 foo -> bar > natalie@natalie:/h/natalie> rm bar > natalie@natalie:/h/natalie> ls `ls -al foo | cut -d">" -f2` > bar not found > natalie@natalie:/h/natalie> echo $? > 2 > natalie@natalie:/h/natalie> Ugh :) Very hackerish, aber ist eine witzige Idee. Also, das mit dem test sollte eigentlich schon funktionieren (Hat bei mir bei [Open|Free]BSD, Linux, Solaris, plan9 funktioniert): zar:/tmp # ls -al foo bar ls: foo: No such file or directory ls: bar: No such file or directory zar:/tmp # ln -s bar foo zar:/tmp # ls -al foo bar ls: bar: No such file or directory lrwxrwxrwx 1 root root 3 Jul 5 11:33 foo -> bar zar:/tmp # test -h foo && echo "file exists" || echo "file non-existant" file exists zar:/tmp # test -e foo && echo "file exists" || echo "file non-existant" file non-existant zar:/tmp # > bar zar:/tmp # ls -al foo bar -rw-r--r-- 1 root root 0 Jul 5 11:33 bar lrwxrwxrwx 1 root root 3 Jul 5 11:33 foo -> bar zar:/tmp # test -h foo && echo "file exists" || echo "file non-existant" file exists zar:/tmp # test -e foo && echo "file exists" || echo "file non-existant" file exists zar:/tmp # Was meinst Du dazu? Wenn das nicht reicht, habe ich noch eine hardcore Variante, die auch auf allen Systemen funktionieren sollte :) Cheers, Roberto Nibali, ratz -- mailto: `echo NrOatSz@tPacA.cMh | sed 's/[NOSPAM]//g'`
Technical Details
Message-ID:
<3B44352A.6CC715F9@tac.ch>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!newsfeed.hanau.net!newsfeed01.sul.t-online.de!t-online.de!newsrouter.chello.at!newsmaster-01.atnet.at!atnet.at!newsfeed-zh.ip-plus.net!news.ip-plus.net!not-for-mailReferences:
<3B441847.381424C4@siemens.ch> <3B441A75.2CF14D98@tac.ch> <3B442D76.F78EB891@siemens.ch>Show Full Headers
Complete Article Headers
X-Google-Language: GERMAN,ASCII-7-bit X-Google-Thread: f4b73,67e615da96b01c88 X-Google-Attributes: gidf4b73,public X-Google-ArrivalTime: 2001-07-05 02:37:02 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!isdnet!fr.clara.net!heighliner.fr.clara.net!newsfeed.hanau.net!newsfeed01.sul.t-online.de!t-online.de!newsrouter.chello.at!newsmaster-01.atnet.at!atnet.at!newsfeed-zh.ip-plus.net!news.ip-plus.net!not-for-mail From: Roberto Nibali <ratz@tac.ch> Newsgroups: ch.comp.os.linux Subject: Re: Pruefen von symbolische links Date: Thu, 05 Jul 2001 11:36:42 +0200 Organization: terreActive Lines: 77 Message-ID: <3B44352A.6CC715F9@tac.ch> References: <3B441847.381424C4@siemens.ch> <3B441A75.2CF14D98@tac.ch> <3B442D76.F78EB891@siemens.ch> NNTP-Posting-Host: 212.28.148.18 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: rex.ip-plus.net 994325820 16783 212.28.148.18 (5 Jul 2001 09:37:00 GMT) X-Complaints-To: abuse@ip-plus.net NNTP-Posting-Date: Thu, 5 Jul 2001 09:37:00 +0000 (UTC) X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.5-ac19 i686) X-Accept-Language: en, de-CH, zh-CN