Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Verify Unix file exists

519 views
Skip to first unread message

Dave Salt

unread,
May 13, 2009, 5:50:15 PM5/13/09
to
In a REXX procedure I need to check if a Unix file exists. If the file name contains imbedded spaces, it needs to be enclosed in quotes before using the STAT service to check if it exists. But if the file name also contains single and double quotes, I can't find the proper syntax for calling the STAT service. For example, let's say the following is the full unix path and file name, including the single and double quotes:

/u/mydir/'ab " cd '

In the following procedure, what value would FNAME need to be set to in order to determine if the file exists?

/* REXX */
fname = ?
address syscall
'stat 'fname' stat.'
if rc = 0 & retval = 0 then say fname" exists"
else do
say "Error processing file: "fname
say "RC = "rc
say "RETVAL = "retval
EXIT 16
end


Thanks for any suggestions!

Dave Salt

SimpList(tm) - try it; you'll get it!
http://www.mackinney.com/products/SIM/simplist.htm
_________________________________________________________________
Windows Live helps you keep up with all your friends, in one place.
http://go.microsoft.com/?linkid=9660826
----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX

Paul Gilmartin

unread,
May 13, 2009, 5:55:47 PM5/13/09
to
On 05/13/09 15:49, Dave Salt wrote:
> In a REXX procedure I need to check if a Unix file exists. If the file name contains imbedded spaces, it needs to be enclosed in quotes before using the STAT service to check if it exists. But if the file name also contains single and double quotes, I can't find the proper syntax for calling the STAT service. For example, let's say the following is the full unix path and file name, including the single and double quotes:
>
> /u/mydir/'ab " cd '
>
> In the following procedure, what value would FNAME need to be set to in order to determine if the file exists?
>
> /* REXX */
> fname = ?
> address syscall
> 'stat 'fname' stat.'
>
Without testing, but years ago in the archives of MVS-OE,
from WJS, IIRC:

'stat (fname) stat.'

(Akin to using Rexx variables in ISPEXEC.)

Such questions are better asked in MVS-OE.

-- gil

Paul Gilmartin

unread,
May 13, 2009, 7:13:32 PM5/13/09
to
On 05/13/09 15:49, Dave Salt wrote:
> In a REXX procedure I need to check if a Unix file exists.
>If the file name contains imbedded spaces, ...
>
> /u/mydir/'ab " cd '
>
Ah, here it is:

Linkname: Specifying strings
URL: http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/BPXZB680/3.1.2

-- gil

Dave Salt

unread,
May 13, 2009, 8:49:45 PM5/13/09
to
Gil,

It works; thank you so much!!!

Dave Salt

SimpList(tm) - try it; you'll get it!
http://www.mackinney.com/products/SIM/simplist.htm

----------------------------------------
> Date: Wed, 13 May 2009 17:12:13 -0600
> From: PaulGB...@AIM.COM
> Subject: Re: Verify Unix file exists
> To: TSO-...@VM.MARIST.EDU

_________________________________________________________________
Find info faster and easier with Internet Explorer 8.
http://go.microsoft.com/?linkid=9655583

Paul Gilmartin

unread,
May 14, 2009, 3:16:32 AM5/14/09
to
On May 13, 2009, at 18:49, Dave Salt wrote:
>
> It works; thank you so much!!!
>
If you need then to ALLOCate a DDNAME to the file, there's
a trick used by the C compiler; effectively:

address SYSCALL
'open (fname) ...'
RC = BPXWDYN( 'alloc path(''/dev/fd'RETVAL''') ... msg(STEM.)' )

Miranda, John

unread,
Jul 30, 2009, 12:21:22 PM7/30/09
to
Has anyone put together a way, using REXX on z/OS, to access data from an Oracle database located on a unix box? We are thinking and investigating if it is possible to: create a REXX executing a USS script to run a java program, the java program will make JDBC calls to get the data. We still are stumped on how to get the data back to the initial calling rexx. We also think to simplify a little bit by have a bpxbatch step execute a .rex script and calling the java program. The .rex would process the returned data on the 'USS side'. Or is there a better way?


Thanks in advance,

John

Bob Stark

unread,
Jul 30, 2009, 12:33:18 PM7/30/09
to
1. There is an Oracle client that could be installed on z/OS.
I have not done this, but I taught at a site who did.
They had Oracle servers running on z/OS as well.
They said they felt "lonely", like there were not that many people
running Oracle on z/OS.
Oracle is an OMVS (USS) application on z/OS.

2. With the java approach, your java program could have command line
arguments to direct it to insert, update, delete, or select. If it did a
select, it could write the data to a file, or to stdout. When the REXX
program launched the java program, it could use piping or redirection to
handle the stdout data, or it could read the file immediately after any
select calls that produced a good sqlcode (0 or 100). It might also delete
the output file before or after each call. I would probably use stdout and
the pipe approach, since it could multi-thread that way.

Regards,

Bob Stark

ProTech - When you're serious about Systems Management
Consulting, Software, and Training for z/OS, UNIX and Internet
www.protechtraining.com 800-373-9188 x151 Cell: 412-445-8072


Thanks in advance,

John

--
If this email is spam, report it here:
http://www.onlymyemail.com/view/?action=reportSpam&Id=Mzg3MzE6OTM5MzkwNDM1Om
JzdGFya0Bwcm90ZWNocHRzLmNvbQ%3D%3D

Robert Zenuk

unread,
Jul 30, 2009, 1:04:45 PM7/30/09
to
About 12 years ago I did something like this. The technique is kind of
old and not allowed in some shops engrained in SSH.

If you allow REXEC between trusted hosts, that might provide a native z/OS
REXX solution... REXEC to the Oracle host and send a command to execute a
script that runs SQLPLUS. The STDOUT will come right back to the REXX
EXEC through REXEC or the OUTPUT DD if you want to do more than just look at
it.

Some shops do not allow REXEC due to passwords being sent in clear text
over the wire. Between trusted hosts within the DMZ, some shops allow it...

Rob


In a message dated 7/30/2009 9:33:13 A.M. US Mountain Standard Time,
bst...@PROTECHPTS.COM writes:

Regards,

Bob Stark


Thanks in advance,

John


**************Hot Deals at Dell on Popular Laptops perfect for Back to
School
(http://pr.atwola.com/promoclk/100126575x1223105306x1201716871/aol?redir=http:%2F%2Faltfarm.mediaplex.com%2Fad%2Fck%2F12309%2D81939%2D1629%2D9)

0 new messages