Copy UNIX File into a DSN with a specific Format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copy UNIX File into a DSN with a specific Format
# 1  
Old 07-19-2013
Lightbulb Copy UNIX File into a DSN with a specific Format

Hi All ,

I am new to programming and here is what i am trying to achieve , i am taking a list of mounted filesystems (based on the HLQ) , passing it on to a txt file and then copying the file to a DSN .The code i am using :

Code:
df | grep WAST.*WASCFG.*ZFS |  awk '{print $2}' | sort -o log.txt | cp  log.txt "//'WAST.PSYSZ.N.WASTZFS1.TDEV'"

The DSN when getting created looks like this this :

Code:
(WAST.PSYSZ.NO**.WASCFG.T****.ZFS)
(WAST.PSYSZ.NO**.WASCFG.T****.ZFS)
(WAST.PSYSZ.NO**.WASCFG.T****.MOUNTPT.ZFS)
(WAST.PSYSZ.NO**.WASCFG.T****.MOUNTPT.ZFS)

the Format (in the DSN) which is required should be :-

Code:
 INCLUDE( -
     WAST.PSYSZ.NO**.WASCFG.T****.ZFS                        -
     WAST.PSYSZ.NO**.WASCFG.T****.ZFS                        -
     WAST.PSYSZ.NO**.WASCFG.T****.MOUNTPT.ZFS                -
     WAST.PSYSZ.NO**.WASCFG.T****.MOUNTPT.ZFS                -
     
      )


Any help would be highly appreciated.

Regards

Last edited by Corona688; 07-19-2013 at 01:21 PM..
# 2  
Old 07-19-2013
Pipes do not work that way. cp does not read from standard input, so there is no point piping into it.

Running them all in pipes means they will all be launched at the same time -- the cp will try to work before the file even exists.

If you're doing awk | grep | sed | cut | kitchen | sink, you might as well do it all in one simple awk command. It does a lot more than cutting columns.

Code:
df | awk '/WAST.*WASCFG.*ZFS/ { print $2 }' | sort > log.txt
cp log.txt /path/to/wherever

Where is WAST.PSYSZ.N.WASTZFS1.TDEV mounted? That is where you need to copy it to, you can't feed the shell a //-style network address.
# 3  
Old 07-19-2013
Thanks Corona,

The feedback about the CP is correct and i have made the changes , however the cp command does work with "//'qualifier.address.**'" format , what i am doing is i am copying the USS file into an MVS Dataset.

My issue still remains the same though the output data set format is still
Code:
(WAST.PSYSZ.NO**.WASCFG.T****.ZFS)
(WAST.PSYSZ.NO**.WASCFG.T****.ZFS)
(WAST.PSYSZ.NO**.WASCFG.T****.MOUNTPT.ZFS)
(WAST.PSYSZ.NO**.WASCFG.T****.MOUNTPT.ZFS)

What i need is the output to the data set should be :-

Code:
INCLUDE( -
     WAST.PSYSZ.NO**.WASCFG.T****.ZFS                        -
     WAST.PSYSZ.NO**.WASCFG.T****.ZFS                        -
     WAST.PSYSZ.NO**.WASCFG.T****.MOUNTPT.ZFS                -
     WAST.PSYSZ.NO**.WASCFG.T****.MOUNTPT.ZFS                -
     
      )


Regards

Last edited by Franklin52; 07-20-2013 at 08:29 AM.. Reason: Please use code tags
# 4  
Old 07-19-2013
Quote:
Originally Posted by AnjanM
The feedback about the CP is correct and i have made the changes , however the cp command does work with "//'qualifier.address.**'" format , what i am doing is i am copying the USS file into an MVS Dataset.
Then that is the mountpoint, and / will work as well as // .

How about this:

Code:
df | awk '/WAST.*WASCFG.*ZFS/ { gsub(/[()]/, "", $2); print $2 }' |
        ( echo "INCLUDE( -"
          sort
          echo ")" ) > log.txt
cp log.txt /path/to/wherever

This User Gave Thanks to Corona688 For This Post:
# 5  
Old 07-22-2013
Hi Corona,

This is what i am using for the script :
Code:
df | awk '/WA**.*WA***.*ZFS/ { print $2 }' | sort >> log.txt
cat log.txt | awk -v var="-" '{printf("%- 50s\t %40s %s\n",$1,$2,var)}' | sed "s/^/      /" | sort >> log1.txt |rm log.txt
cat log1.txt |tr -d '()'|awk 'BEGIN {print "   INPUT(- " } {print $0}' >> log2.txt | rm log1.txt
cat log2.txt | echo "    )" >> log2.txt

The output which i get is in the desired format :-
Code:
INPUT(-
      WA**.P**.**MVS.WA**.**NODE.ZFS                             -
      WA**.P**.**MVS.WA**.**TDNODE.ZFS                         -
      WA**.P**.**MVS.WA**.**TDNODE.MOU***.ZFS             -


Here is the problem which i am facing:-

I am able to copy the file into an MVS dataset however when viewing the Dataset on mainfrmae it says :-
"Data contains invalid (non-display) characters"

So i view the file in Unix using vi and when i do a :set list -
Code:
 INPUT(- $
     WA**.P**.**MVS.WA**.**NODE.ZFS                        ^I      -$
    WA**.P**.**MVS.WA**.**TDNODE.ZFS                     ^I      -$
    WWA**.P**.**MVS.WA**.**TDNODE.MOU***.ZFS      ^I      -$

My question is how to get rid of ^I from the file because i believe that is a special character which MVS is detecting.

---------- Post updated at 04:11 PM ---------- Previous update was at 03:49 PM ----------

Please ignore my last post , a very silly mistake on my part .the ^I is a tab and it was showing since my Awk length had \t in it ,once i removed that it has been fixed now.

Once again thanks Corona for your inputs yesterday

Last edited by Franklin52; 07-23-2013 at 10:37 AM.. Reason: Please use code tags
# 6  
Old 07-22-2013
Why are you piping into rm ? It does not read from standard input, any more than cp does.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

I cannot find dsn and TNSNAMES.ora on UNIX

Where can I find dsn and TNSNAMES.ora on UNIX AIX Thanks for contribution (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Shell Programming and Scripting

Find and Copy file of specific location

Dear All, I need to transfer all files present in one location to another but those files should be of specific extension like. Find and copy all files of extension .xls, .pdf, .txt from location usr/tmp to location /per/Treat (6 Replies)
Discussion started by: yadavricky
6 Replies

3. Shell Programming and Scripting

Copy specific file (different but same name) as folder name

I have to copy a particular file present in a main folder having part of the file-name present in many sub-folders to a new destination preserving the name of the source "part of the main folder" and previous file-name of the output file: Example: From /005_0/1000/005.xxx ->... (7 Replies)
Discussion started by: wappor
7 Replies

4. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 Replies

5. Shell Programming and Scripting

How to copy specific files when you don't know the file name?

I hope this isn't as silly as it sounds from the title of the thread. I have software that outputs files where the name starts with a real number followed by underscore as a prefix to an input file name. These will list in the directory with the file with the smallest real number prefix as the... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

6. Shell Programming and Scripting

Converting windows format file to unix format using script

Hi, I am having couple of files which i used to copy from windows to Linux, so now in case of text files (CTRL^M) appears at end of line. I know i can convert this windows format file to unix format file by running dos2unix. My requirement here is that i want to do it automatically using a... (5 Replies)
Discussion started by: sarbjit
5 Replies

7. Shell Programming and Scripting

How to check for file name of specific format using find?

I have to find the specific formatted file is present in the received list in the directory, for which I have written: file_list=`ls -lrt /tmp/vinay/act/files |grep "$cdate"| awk '{print $9}'` while read fileStr do find $file_list $fileStr > /dev/null status=`echo $?` if ; then ... (3 Replies)
Discussion started by: IND123
3 Replies

8. Shell Programming and Scripting

How to copy specific file.txt in specific folder?

hye there... i have a problem to copy file in specific folder that will change the name according to host,time(%m%s) and date(%Y%M%D) example folder name: host_20100531.154101801 this folder name will always change... but i just want to copy the AAA.txt and BBB.txt file.. really need... (17 Replies)
Discussion started by: annetote
17 Replies

9. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

10. Shell Programming and Scripting

Bash copy file contents into an existing file at a specific location

Hi all I need to copy the entire contents of one file into an existing file at a specific location. I know the exact line number where I need to put it. It appears I would use either sed or awk to do this, but I have been unsuccessful so far: File A line 1 line 2 line 3 line 4 ... (6 Replies)
Discussion started by: gshepherd7
6 Replies
Login or Register to Ask a Question