Odds and Ends
November 14, 2007 Hey, Professional
It’s been a while since we ran an article of odds and ends. Here are several short tips for working with the Integrated File System (IFS). I hope you find something useful. Question: The Work with Object Links (WRKLNK) panel doesn’t show complete file names. What I see is the first 18 characters of a file name, a space, and a greater-than sign, like this: Sales (3Q-2007) Re > Sales (3Q-2007) Re > Sales (3Q-2007) Re > Sales (3Q-2007) Re > Sales (3Q-2007) Re > Is there a way to make it show the complete names? Answer: You’re close. Just add DETAIL(*NAME) to the WRKLNK command. WRKLNK OBJ('/tmp/salesanalysis/*') DETAIL(*NAME) You can also use DETAIL(*NAME) with the Display Object Links (DSPLNK) command to see complete file names. DSPLNK OBJ('/tmp/salesanalysis/*') DETAIL(*NAME) Also, try Qshell’s “ls” utility, with a one-switch instead. ls -1 Sales (3Q-2007) Region 1.xml Sales (3Q-2007) Region 2.xml Sales (3Q-2007) Region 3.xml Sales (3Q-2007) Region 4.xml Sales (3Q-2007) Region 5.xml The one-switch tells it to list one file per line. Question: We are creating a scheduled process to transmit files from an IFS directory. Sometimes there may be no files to transmit when the scheduled job activates. I would like to add a preliminary step to count the files in that particular directory and then abort the remainder of the process if there are no files to process. We will be transmitting via SFTP using Qshell commands encapsulated in a CL driver program. This would seem very simple, but I’ve looked and I can’t find a simple Qshell method to count files in a directory. BTW, there will be no links and no subdirectories either. Answer: You can use the “wc” utility (with the ell-switch) to count the number of files in a directory. ls | wc -l The problem is getting the data back to the CL program. One method you might try is to create a data area to hold the count. CL has a command just for that. crtdtaara mylib/filecount *char 24 In your Qshell script, use the “datarea” (notice the goofy spelling) utility to stuff the file count into the data area. ls | wc -l | datarea -w /qsys.lib/mylib.lib/filecount.dtaara Getting data back from Qshell is always a problem. I haven’t found a solution that I like yet. You might also want to take a look at this thread in the IT Jungle Web Forums. Question: Suppose I want to use the Work with Object Links (WRKLNK) command with files that whose names contain the string “rtv.” I thought I could use the wild card character to get a subset list. wrklnk '*rtv*' But the system responds with error CPD0816 (Path name cannot begin with *.) and CPF0001 (Error found on WRKLNK command.) What do I do? Answer: Preposterous, ain’t it? Prefix the wild card expression with a period and a slash. wrklnk './*rtv*' The period stands for the current directory. Question: Can you help me with an FTP script? I want to transfer files from the Integrated File System into a Windows directory. Answer: Are you running the FTP client on the PC? If so, put the following commands after the login sequence: quote site namefmt 1 get /home/myfile.txt c:tempmyfile.txt Substitute the proper paths and file names in the “get” command. You will have an ASCII transfer by default, which is probably what you want. If not, use the “bin” command to transfer in binary mode. Reader Feedback Hey Ted: I read your tips and enjoy them a lot. Your tips inspired me to dive into IFS and Qshell. I tried your tip Finding Large IFS Directories and it is very cool. There is a small point that I noticed and would like to share with all. I noticed that there were some class files in my IFS directory against which I could not see a * by using the -F option with the ls command. (The -F switch appends / to directory names, * to executables, and @ to symbolic links.) After looking for a while, I found that one should have explicit execute authority (-x) over a file to see this -F option to show the expected results. Please keep on posting more IFS tricks and tips. –Pankaj
|