Chris;
Below is the code from my moveIfsFile procedure as an example, you don't read the file, all you need to have is the from path and the to path.
Note for understanding the logic: trapErrNo() throws an exception, using the errNo value and message unless the 3rd parm is specified, it also returns the errNo value
Duane Christen
D moveDirectoryEntry...
D PI
D fromPath * Value Options(*STRING) from Path
D toPath * Value Options(*STRING) To Path
D errorStructure... Error Structure
D * Value
If link(fromPath : toPath) <> 0;
trapErrNo(errNo : 'link');
EndIf;
If unLink(fromPath) <> 0;
If trapErrNo(errNo : 'unlink' : '*DIAG') = 3500;
CapCmdCommand = 'CHGATR OBJ(' + delimit(%Str(fromPath)) + ') +
ATR(*READONLY) +
VALUE(*NO)';
/Include QRpgCbSrc,CQCapCmd
If unLink(fromPath) <> 0;
trapErrNo(errNo : 'unlink' : '*DIAG');
EndIf;
EndIf;
EndIf;
--
Duane Christen
Senior Software Engineer
(319) 790-7162
Duane.Christen@xxxxxxxxxx
Visit PAETEC.COM
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Chris Bipes
Sent: Thursday, November 12, 2009 2:42 PM
To: Midrange Systems Technical Discussion
Subject: RE: opendir() - THE ANSWER
Yes I can:
1. open the directory
2. read a directory entry
3. get the status to determine if it is a file or directory or symbolic link 4. if file Open the file 5. create the new file (link) 6. Open the new file Loop till done 7. read old file 8. write new file End loop 9. unlink (delete) the old file.
10. change the new file attributes to be the same as the original file
But it is easier to just move the file. And the move command retains the original file attributes, which I want to keep the modified date intact.
Chris Bipes
Director of Information Services
CrossCheck, Inc.
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Christen, Duane
Sent: Thursday, November 12, 2009 12:32 PM
To: Midrange Systems Technical Discussion
Subject: RE: opendir() - THE ANSWER
Chris;
Do link() and unLink() fit your circumstances? These are what my moveIfsFile procedure are built with.
Duane Christen
--
Duane Christen
Senior Software Engineer
(319) 790-7162
Duane.Christen@xxxxxxxxxx
Visit PAETEC.COM
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Chris Bipes
Sent: Thursday, November 12, 2009 2:20 PM
To: Midrange Systems Technical Discussion
Subject: RE: opendir() - THE ANSWER
Ok I am just going with using the system API and the MOV command. It works. I was just hoping to find the API / Program behind the command so I would not be adding that additional workload. Guess it just is not worth the effort as all the APIs I have found don't seem to move between servers.
Chris Bipes
Director of Information Services
CrossCheck, Inc.
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Thursday, November 12, 2009 11:54 AM
To: Midrange Systems Technical Discussion
Subject: Re: opendir() - THE ANSWER
Vern,
This is a bad idea. The programs in the QSHELL library are meant to be used inside the QShell environment.
There are all sorts of things that are set up in that environment...
this includes the standard I/O streams being set up a particular way, certain environment variables being set up a particular way, certain descriptor set up, the services of a shell and all of the stuff that the
shell does for you, being spawned a separate child job, etc.
These programs are written with the expectation that they will have all of that stuff set up. If you call the programs directly, you are using them in a manner that they weren't intended to be used!
If they happen to work because they don't happen to require the QShell environment right now... well, okay, I guess they'll work then. But you
can't rely on that being the case going forward. Your app may work today, then you might do a release upgrade or install a PTF and it may stop working.
It's just not a good idea to use software in a manner that it wasn't intended for!
If you're really THAT hard-up for a MV utility, you'd be better off finding an open source one and taking the relevant pieces of code out of
it so you can use it on i.
But I really don't see the value in calling the QShell MV command here.
why not just use the CL MOV command? That'll be more efficient than the Qshell variety, and you'll be using it from the interface it was deisgned for.
Just write a simple little wrapper program like this:
PGM PARM(&FROM &TO)
DCL VAR(&FROM) TYPE(*CHAR) LEN(500)
DCL VAR(&TO) TYPE(*CHAR) LEN(500)
MOV OBJ(&FROM) TOOBJ(&TO)
ENDPGM
Compile that as a CL program (or if you prefer, as a CL module and bind it to your RPG) then you can call it willy-nilly.
Vern Hamberg wrote:
Every command in QShell is a symbolic link to a program - those
programs
handle parameters the way a C program does - in my experience. There
is
a MV command in QShell, and its program is QSHELL/MV. This is an
example
of using it that does just what you want -
call QSHELL/MV ('/home/vern/aab.txt' '/home/aab.txt')
Scott, here's a chance for another article!!
I figured this out about 6 years ago and had forgot it. If you want it
not to prompt when replacing, add a parameter with value '-f'.
Whoopee!!
Vern
Chris Bipes wrote:
Not so crazy.. But how to write records to a iSeries Database from
within that shell script? Then make it wake up an process the
directory
until empty every few minutes. We receive images from our customers,
thousands a day, and move them from our FTP and WEB servers,
currently
to a windows 2003 server. Our problem has been finding images when
we
have too many files in one directory. This is why we are building a
database as the images come in, move them to our NAS which we have
mounted an empty IFS directory over. Then we can search the database
to
find the image and know exactly where it is.
Chris Bipes
Director of Information Services
CrossCheck, Inc.
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Vern Hamberg
Sent: Thursday, November 12, 2009 9:24 AM
To: Midrange Systems Technical Discussion
Subject: Re: opendir()
Chris
Here's a crazy idea - write a shell script and run it in PASE!
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/midrange-l.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.