Jak zjistit pid aktualniho skriptu ...
Honza Pazdziora
adelton na informatics.muni.cz
Úterý Září 24 09:44:42 MEST 2002
On Tue, Sep 24, 2002 at 09:34:48AM +0200, Petr Ruzicka wrote:
> Muze mi nekdo napsat jak se da zjistit pid aktualniho procesu (nebo jak
> se tomu rika - ted si nemuzu vzpomenout) V shellu to bylo : $$
Intuitivne, $$.
> (doufam). Jeste mam nasledujici problemek. V prikladu je uvedeno
> otevreni (a spusteni) neznameho prikazu. V prvnim otevrenim(spustenim)
> je
> vse
> v
> poradku a vypise se neco jako : LOOK1 at ./pokus line 2. Zato pri
> druhem open se nic nevypise - je to zpusobeno temi uvozovkami. Muze mi
> nekdo poradit jak to udelat, aby pri spusteni nejakeho neznameho
> prikazu (ktery obsahuje nejakou cast v uvozovkach) pomoci open se mi
> napsala chybova hlaska a program se ukoncil (pomoci die).
> Konkretne spoustim : /usr/sbin/smbmount "//xxx/x"
> "/xxx/xxx/xxx/x" (+ dalsi parametry) - a chtel bych pokud by na tomto
> miste smbmount neexistoval tak skoncit a nahlasit chybu
>
> Priklad:
> #!/usr/bin/perl
> open(P,"neznamy_prikaz pokus |") or die "LOOK1";
> print "OK1";
>
> open(P,"neznamy_prikaz \"pokus\" |") or die "LOOK2";
> print "OK2";
>
> Dekuji za pomoc ....
On Vam totiz nefunguje ani ten prvni prikaz (cituji z man perlipc):
Be careful to check both the open() and the close() return
values. If you're writing to a pipe, you should also trap
SIGPIPE. Otherwise, think of what happens when you start up
a pipe to a command that doesn't exist: the open() will in
all likelihood succeed (it only reflects the fork()'s
success), but then your output will fail--spectacularly.
Perl can't know whether the command worked because your
command is actually running in a separate process whose
exec() might have failed. Therefore, while readers of bogus
Cili napriklad na mem stroji nevypise die ani jeden z nich.
> P.S. Muze mi nekdo doporucit nejakou dobrou knihu o Perlu? Moje starsi
> zacatecnicka mi trochu prestava stacit :-)
Programming Perl, Perl in a Nutshell. Plus manove stranky
(dokumentace).
--
------------------------------------------------------------------------
Honza Pazdziora | adelton na fi.muni.cz | http://www.fi.muni.cz/~adelton/
... all of these signs saying sorry but we're closed ...
------------------------------------------------------------------------
Další informace o konferenci Perl