From owner-freebsd-questions Tue Dec 4 19:56:12 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mail7.carolina.rr.com (fe7.southeast.rr.com [24.93.67.54]) by hub.freebsd.org (Postfix) with ESMTP id D6E6B37B417 for ; Tue, 4 Dec 2001 19:56:07 -0800 (PST) Received: from snafu.enterit.com ([66.57.159.198]) by mail7.carolina.rr.com with Microsoft SMTPSVC(5.5.1877.687.68); Tue, 4 Dec 2001 22:56:05 -0500 Message-Id: <5.1.0.14.0.20011204231702.02730038@mail.enterit.com> X-Sender: jconner@enterit.com@mail.enterit.com X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 04 Dec 2001 23:19:58 -0500 To: freebsd-questions@FreeBSD.ORG From: Jim Conner Subject: Re: How to make a start/stop/restart script -- Fwd: Undeliverable Mail Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I was out of town when I tried to send this. It bounced so I am not sure if it went through (got well over 10,000 email messages while I was gone) because I didn't see it come through. Anyhoo, just thought I would make sure that it got through to the list. - Jim >Date: Tue, 27 Nov 2001 14:07:35 -0500 >From: "Postmaster" >Sender: >To: >Subject: Undeliverable Mail >X-Mailer: > >Delivery failed 3 attempts: freebsd-questions@FreeBSD.ORG > > >Original message follows. > >Date: Tue, 27 Nov 2001 13:13:50 -0500 >Message-Id: <200111271313.AA4194478@enterit.com> >Mime-Version: 1.0 >Content-Type: text/plain; charset=ISO-8859-1 >Content-Transfer-Encoding: quoted-printable >From: "jconner" >Reply-To: >To: freebsd-questions , > S=?ISO-8859-1?Q?=F8?=ren Neigaard >Subject: Re: How to make a start/stop/restart script >X-Mailer: > > >---------- Original Message ---------------------------------- >From: S=F8ren Neigaard >Date: 27 Nov 2001 18:57:11 +0100 > > >Sorry for the offtopic mail, but I know you guys know the answer :) > >This isn't really off-topic :) > > > > >How do I make a script that can start/stop/restart a Java process? > >Somting about probing the process string, but how do I do it!? > > > >It has to work on both Unix and Linux too :) > >I won't go into the specifics of it but it is not that difficult to do. Yo= >ur questions more like you're interested in knowing how to kill the process= > vs starting the process. The other thing is that you are wanting it to wo= >rk on multiple *nix boxen which means a lil bit more work (but not much). > >First, you need to learn case...esac statements. > >case $1 in > start) do something here;; > stop) do something here;; > *) default message (usually an echo to STDOUT for usage) >esac > >You will also want to use the case..esac statement for the multiple OS's...= > > >case $(uname -s) in > FreeBSD) psargs=3D"u $LOGNAME";; > SunOS) psargs=3D"-f -u $LOGNAME" > *) exit 10;; >esac > >Once that is set then in you stop) section of the first case statement you = >can call the ps with the $psargs set in the second case statement. > >Here, let me wrap this up with a small example using what I have up there. > > ># Start/Stop script (simple and unfinished) ># Example by Jim Conner (MJ, TN;CHT, NC;LA, CA) > >funcUsage() { > echo "ERROR: $1" > cat << EOM >Usage: $shProgName [start|stop|etc etc]" > >explanation > >[message truncated] - Jim -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- http://www.perlmonks.org/index.pl?node_id=67861&lastnode_id=67861 -----BEGIN PERL GEEK CODE BLOCK----- ------BEGIN GEEK CODE BLOCK------ Version: 0.01 Version: 3.12 P++>*@$c?P6?R+++>++++@$M GIT/CM/J d++(--) s++:++ a- >++++$O!MA->++++E!> PU-->+++BD C++++(+) UB++++$L++++$S++++$ $C-@D!>++++(-)$S++++@$X?WP+>++++MO!>+++ P++(+)>+++++ L+++(++++)>+++++$ !E* +PP+++>++++n-CO?PO!o >++++G W++(+++) N+ o !K w--- PS---(-)@ PE >*(!)$A-->++++@$Ee---(-)Ev++uL++>*@$uB+ Y+>+++ PGP t+(+++)>+++@ 5- X++ R@ >*@$uS+>*@$uH+uo+w-@$m! tv+ b? DI-(+++) D+++(++) G(++++) ------END PERL GEEK CODE BLOCK------ ------END GEEK CODE BLOCK------ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message