help with unix commands
David Williams
David_Williams at westbury-homes.co.uk
Wed Jan 25 10:58:40 CST 2006
Paul
while UNIX is fun, I doubt if it is progress from MPE.
I haven't seen MPE, but I think all proprietary systems are likely to be
more consistent and rigorous than UNIX. (I hated it at first, but
confess I'm fond of it now).
Getting status from UNIX commands tends to be not that helpful, as
generally it's 0 (OK) or anything else not OK, or whatever the writer
felt like, and the writer may well have been on dope when writing.....
The sort of thing of thing you could do if you're determined (in the
grep example where we've got 0, 1, or 2) :
in quick retrieve the UNIX process id to get unique key.
(getsystemval?).
Put in say t_pid
pass this to a script to run the grep
let t_command = pack ("grepscript " + t_pid)
grepscript would be along the lines of:
PIDPARM=$1
grep abc filexx > /dev/null 2>&1
RESULT=$?
touch file_$PIDPARM_$RESULT
exit 0
You should now have a file. If process id was 5000, you should have
file_5000_0 or file_5000_1 or file_5000_2
You could then use Ole's method to test for the status you're interested
in.
(And then delete the file with a run command for tidiness).
------------------------------------------------------
Have just seen mail from Stephen on commandcode
In just ONE of our programs there is use of something called
COMMANDCODE. It's an absolete program I'm afraid, so I don't know if it
worked ...
(the script it calls jobsize was used to distribute CAD drawings to one
of 50 UNIX CAD stations)
let t'command = "/usr/local/bin/jobsize " + downshift(t'machine) + "
" + &
t'parm_string
run command t'command on error continue
if not commandok
then begin
if commandcode[8:5] = "#0001"
then error "Invalid machine name, please re-enter"
if commandcode[8:5] = "#0002"
then error &
"There is insufficient space on this machine. Please try another"
if commandcode[8:5] = "#0003"
then error &
"One of the CAD models is missing from the relevant directory"
end
David
-----Original Message-----
From:
powerh-l-bounces+david_williams=westbury-homes.co.uk at lists.sowder.com
[mailto:powerh-l-bounces+david_williams=westbury-homes.co.uk at lists.sowde
r.com] On Behalf Of PAUL DIACONESCU
Sent: 25 January 2006 16:10
To: powerh-l at lists.sowder.com
Subject: RE: help with unix commands
Hi all,
Ole's methode works fine for this particular command. Thank you.
But I still can not beleive that you can not retrieve the exit status
($?)
in the quick program.
Where is the progress migrating from MPE to UNIX ? It looks look like a
'regress'.
Paul Diaconescu
>From: "David Williams" <David_Williams at westbury-homes.co.uk>
>To: "PAUL DIACONESCU" <paul_diaconescu at hotmail.com>,
><powerh-l at lists.sowder.com>
>Subject: RE: help with unix commands
>Date: Wed, 25 Jan 2006 15:54:20 -0000
>
>Paul
>
>I don't think you can't get the status without getting into convoluted
>saving in the script and accessing in the quick, because the command is
>spawned at a lower unix shell level.
>
>But if you just want to decide whether you found abc or not then using
>Ole's method should work :
>
>
> >let cmd_str = "grep abc filexx > /dev/null 2>&1"
> >run command cmd_str nowarn on error continue if commandok
> > then let abcexists = "true"
> > else let abcexists = "false"
>
>(We tend to execute scripts in run command rather than direct command
>line, so if I've got syntax problems above, apologies. I've added the
>2<&1 to your grep to prevent error messages showing).
>
>
>David
>
>-----Original Message-----
>From:
>powerh-l-bounces+david_williams=westbury-homes.co.uk at lists.sowder.com
>[mailto:powerh-l-bounces+david_williams=westbury-homes.co.uk at lists.sowd
e
>r.com] On Behalf Of PAUL DIACONESCU
>Sent: 25 January 2006 15:24
>To: powerh-l at lists.sowder.com
>Subject: RE: help with unix commands
>
>Thank-you for your answer.
>I do not want to check for the existence of a file.
>I want to check for the existence of one or more lines containing 'abc'
>on a
>particular file
>The 'grep' command exits with status = 0 if any lines match, 1 if not
>and 2
>for erreors.
>How can I retrieve the exit-status ($?) in the quick program ?
>paul diaconescu
>
>
> >From: "Ole Hansen, ScanConsult" <oh at scanconsult.dk>
> >Reply-To: oh at scanconsult.dk
> >To: "'PAUL DIACONESCU'" <paul_diaconescu at hotmail.com>,
> ><powerh-l at lists.sowder.com>
> >Subject: RE: help with unix commands
> >Date: Wed, 25 Jan 2006 16:11:46 +0100
> >
> >Paul,
> >
> >I can't answer your question, but I have a feeling that you wish to
>test
> >for
> >existence of af particular file. If my feeling is correct, here is
what
>we
> >do:
> >
> >let cmd_str = "ls $HOME/filename" ; change to point to correct file
> >run command cmd_str nowarn on error continue
> >if commandok
> > then let fileexists = "1"
> > else let fileexists = "0"
> >
> >... otherwise - sorry for the wasted bandwidth.
> >
> >Mange hilsner / With kind regards
> >
> >Ole Hansen
> >
> >===========================================================
> >E-mail: oh at scanconsult.dk Cell Phone: +45 4040 1150
> >===========================================================
> >ScanConsult IT-Partners ApS Voice : +45 7734 7474
> >Jegstrupvej 96A Fax : +45 8738 1416
> >DK-8361 Hasselager Support : support at scanconsult.dk
> >Denmark Sales : sales at scanconsult.dk
> > http://www.scanconsult.dk
> >= ParaSuite : A Suite of Air Cargo Handling solutions =
> >= Partners : Hewlett-Packard, Cognos, Microsoft and more =
> >
> >
> >-----Original Message-----
> >From: powerh-l-bounces+oh=scanconsult.dk at lists.sowder.com
> >[mailto:powerh-l-bounces+oh=scanconsult.dk at lists.sowder.com] On
Behalf
>Of
> >PAUL DIACONESCU
> >Sent: 25. januar 2006 15:52
> >To: powerh-l at lists.sowder.com
> >Subject: help with unix commands
> >
> >quick, on hp unix.
> >
> >I try to do a <RUN COMMAND "grep 'abc' filexx > /dev/null>
> >
> >In unix this command exits with a status ($?) = 0, 1 or 2.
> >
> >How can I retrieve this status ($?) in my quick screen ?
> >
> >paul diaconescu
> >
> >
> >--
> >= = = = = = = = = = = = = = = = = = = = = = = = = = = = Mailing list:
> >powerh-l at lists.sowder.com
> >Subscribe: "subscribe" in message body to
>powerh-l-request at lists.sowder.com
> >Unsubscribe: "unsubscribe <password>" in message body to
> >powerh-l-request at lists.sowder.com
> >http://lists.sowder.com/mailman/listinfo/powerh-l
> >This list is closed, thus to post to the list you must be a
subscriber.
> >
> >--
> >= = = = = = = = = = = = = = = = = = = = = = = = = = = =
> >Mailing list: powerh-l at lists.sowder.com
> >Subscribe: "subscribe" in message body to
>powerh-l-request at lists.sowder.com
> >Unsubscribe: "unsubscribe <password>" in message body to
> >powerh-l-request at lists.sowder.com
> >http://lists.sowder.com/mailman/listinfo/powerh-l
> >This list is closed, thus to post to the list you must be a
subscriber.
>
>
>--
>= = = = = = = = = = = = = = = = = = = = = = = = = = = =
>Mailing list: powerh-l at lists.sowder.com
>Subscribe: "subscribe" in message body to
>powerh-l-request at lists.sowder.com
>Unsubscribe: "unsubscribe <password>" in message body to
>powerh-l-request at lists.sowder.com
>http://lists.sowder.com/mailman/listinfo/powerh-l
>This list is closed, thus to post to the list you must be a subscriber.
>
>
>----------------------------------------------------------------------
>**********************************************************************
>The above information is confidential to the Addressee and may be
>privileged. Unauthorised access and use is prohibited.
>
>Internet communications are not secure and therefore this Company does
not
>accept legal responsibility for the contents of this message.
>
>If you are not the intended recipient, any disclosure, copying,
>distribution or any action taken or omitted to be taken in reliance on
it,
>is prohibited and may be unlawful.
>**********************************************************************
--
= = = = = = = = = = = = = = = = = = = = = = = = = = = =
Mailing list: powerh-l at lists.sowder.com
Subscribe: "subscribe" in message body to
powerh-l-request at lists.sowder.com
Unsubscribe: "unsubscribe <password>" in message body to
powerh-l-request at lists.sowder.com
http://lists.sowder.com/mailman/listinfo/powerh-l
This list is closed, thus to post to the list you must be a subscriber.
----------------------------------------------------------------------
**********************************************************************
The above information is confidential to the Addressee and may be privileged. Unauthorised access and use is prohibited.
Internet communications are not secure and therefore this Company does not accept legal responsibility for the contents of this message.
If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
**********************************************************************
More information about the powerh-l
mailing list