I am pretty new to COZB. We are creating a JCL in which we ftp a file to a remote server. We would like to read the file and brake it down into individual client files in the server.
The job will be something like this:
//RUNCOZ EXEC PROC=COZB
//FILE1 DD DISP=SHR,
// DSN=INPUT.FILE
//SYSOUT DD SYSOUT=*
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDIN DD DISP=SHR,
// DSN=PARM.WITH.TARGET.SERVER(JDRVCOZB)
// DD *
rmtfl1="Billing_$currdtime.txt"
cozsftp $ssh_opts -k $JES_SYSUID -b- $remoteuser@$server <<EOB
lzopts mode=text,servercp=ISO8859-1
cd /target/directory
put //DD:FILE1 $rmtfl1
#script to read and process $rmtfl1
while IFS=',' read v1 v2 v3 v4
if $v1 == 'something' then
output new client file
fi
done
EOB
/*
//
What will I need to be able to run the script after placing the file in server?
Reading a file in target server after ftp
Re: Reading a file in target server after ftp
The lines between "<<EOB" and "EOB" is a "here document" that is input to the cozsftp command, which are subcommands.
So, you can't embed shell script language in here.
You would have to write your shell script outside of the cozsftp command, although it would then be possible to generate "get" or "put" commands that are fed into the cozsftp command as subcommands.
So, you can't embed shell script language in here.
You would have to write your shell script outside of the cozsftp command, although it would then be possible to generate "get" or "put" commands that are fed into the cozsftp command as subcommands.
-
- Posts: 7
- Joined: Wed Dec 14, 2016 11:32 am
Re: Reading a file in target server after ftp
I made a change to run this script;
fromdsn -x shr //DD:FILE1 > /u/coz/someid/billrpt.txt
b="EM_CLNT_ID"
fromdsn -x shr //DD:FILE1 | while IFS=',' read v1 v2 v3 v4 v5 v6 v7 \
V7 v8 v9 v10
do
if ["$v1" == "$b"]
then
echo "$v1"
else
echo "$v1 $v2 $v3 $v4 $v5 $v6 $v7 $v8 $v9 $v10"
fi
done
/*
//
v1 is equal to "EM_CLNT_ID" on the first record, however it will only execute the echo "$v1 $v2" statement, which does echo the data in those variables and which are correct, and get this message regardless if I use if ["$v1" == "$b"] , if [[ "$v1" == "$b" ]], if [ "$v1" = "$b" ]
[EM_CLNT_ID: FSUM7351 not found
I have tried multiple variations of the if statement to compare the variable but get about the same output
BTW Iam not currently running the ftp command
fromdsn -x shr //DD:FILE1 > /u/coz/someid/billrpt.txt
b="EM_CLNT_ID"
fromdsn -x shr //DD:FILE1 | while IFS=',' read v1 v2 v3 v4 v5 v6 v7 \
V7 v8 v9 v10
do
if ["$v1" == "$b"]
then
echo "$v1"
else
echo "$v1 $v2 $v3 $v4 $v5 $v6 $v7 $v8 $v9 $v10"
fi
done
/*
//
v1 is equal to "EM_CLNT_ID" on the first record, however it will only execute the echo "$v1 $v2" statement, which does echo the data in those variables and which are correct, and get this message regardless if I use if ["$v1" == "$b"] , if [[ "$v1" == "$b" ]], if [ "$v1" = "$b" ]
[EM_CLNT_ID: FSUM7351 not found
I have tried multiple variations of the if statement to compare the variable but get about the same output
BTW Iam not currently running the ftp command
-
- Posts: 7
- Joined: Wed Dec 14, 2016 11:32 am
Re: Reading a file in target server after ftp
I figured it out how to verify the data in the desired variable by adding this statement:
if echo "$v1" | grep -q EM_CLNT_ID
If there are any other suggestions feel free to provide those.
Thanks
if echo "$v1" | grep -q EM_CLNT_ID
If there are any other suggestions feel free to provide those.
Thanks
-
- Posts: 7
- Joined: Wed Dec 14, 2016 11:32 am
Re: Reading a file in target server after ftp
Following question have to do with the same subject.
Can we use COZBATCH to read a file from mainframe do some processing and write the output into a file in the LAN server/drive?
If it can be done can someone supply an example on how is done?
Can we use COZBATCH to read a file from mainframe do some processing and write the output into a file in the LAN server/drive?
If it can be done can someone supply an example on how is done?
Re: Reading a file in target server after ftp
Where do you want to do processing of the file?
-
- Posts: 7
- Joined: Wed Dec 14, 2016 11:32 am
Re: Reading a file in target server after ftp
If I understand correctly it takes less resources to do it in the server. The file contains multiple clients and I need to brake the file and write the records to each client file in the LAN server(drive)
However is more efficient.
However is more efficient.
Re: Reading a file in target server after ftp
Co:Z Batch is a utility that runs a z/OS Unix shell in batch
Co:Z SFTP is a SFTP client and server for z/OS. The client is a z/OS Unix command "cozsftp", which is commonly run under Co:Z Batch.
It does file transfer using the standard SSH/SFTP protocol.
Co:Z Launcher (Hybrid batch) is probably most appropriate for what you are asking for, since you can use it from a batch job to launch processes on a remote server that use z/OS data setsfrom the launching batch job set.
See: https://www.youtube.com/embed/WlZbN_vs7us
and: https://dovetail.com/products/hybridbatch.html
and: https://dovetail.com/docs/coz/index.html
Co:Z SFTP is a SFTP client and server for z/OS. The client is a z/OS Unix command "cozsftp", which is commonly run under Co:Z Batch.
It does file transfer using the standard SSH/SFTP protocol.
Co:Z Launcher (Hybrid batch) is probably most appropriate for what you are asking for, since you can use it from a batch job to launch processes on a remote server that use z/OS data setsfrom the launching batch job set.
See: https://www.youtube.com/embed/WlZbN_vs7us
and: https://dovetail.com/products/hybridbatch.html
and: https://dovetail.com/docs/coz/index.html
-
- Posts: 7
- Joined: Wed Dec 14, 2016 11:32 am
Re: Reading a file in target server after ftp
Thanks dovetail.
I will look into those and see if I can figured out how to do this. I like to try to figured things out first and when I get stuck then I will ask for help. Getting there little by little.
I will look into those and see if I can figured out how to do this. I like to try to figured things out first and when I get stuck then I will ask for help. Getting there little by little.
-
- Posts: 7
- Joined: Wed Dec 14, 2016 11:32 am
Re: Reading a file in target server after ftp
Have a file with three clients.
The following code splits the records by clients. I get the first two files in the the folder but not getting the last report since the $emclnt variable is not resolving to the correct client id.
What I am missing or what I have wrong in the code?
echo "$dir"
fromdsn -x shr //DD:FILE1 | while IFS=',' read v1 v2 v3 v4 v5 v6 v7 \
v8 v9 v10 V11
do
if test "$v1" = "EM_CLNT_ID"
then
header=`echo "$v1,$v2,$v3,$v4,$v5,$v6,$v7,$v8,$v9,$v10,$v11"`
echo "$header"
emclnt=$v1
elif test "$emclnt" = "EM_CLNT_ID"
then
dttime=`date "+%Y%m%d.%H%M%S"`
emclnt=$v1
echo "$header" >> EM$emclnt.BillRpt.$dttime.csv
echo "$v1,$v2,$v3,$v4,$v5,$v6,$v7,$v8,$v9,$v10,$v11" >> \
EM$emclnt.BillRpt.$dttime.csv
elif test "$emclnt" = "$v1"
then
echo "$v1,$v2,$v3,$v4,$v5,$v6,$v7,$v8,$v9,$v10,$v11" >> \
EM$emclnt.BillRpt.$dttime.csv
emclnt=$v1
elif test "$emclnt" != "$v1"
then
echo "$emclnt & $v1"
cozsftp $ssh_opts -k $JES_SYSUID -b- $remoteuser@$server <<EOF
lzopts mode=text,servercp=ISO8859-1
cd $dir
put EM$emclnt.BillRpt.$dttime.csv
EOF
emclnt="$v1"
echo "$header" >> EM$emclnt.BillRpt.$dttime.csv
echo "$v1,$v2,$v3,$v4,$v5,$v6,$v7,$v8,$v9,$v10,$v11" >> \
EM$emclnt.BillRpt.$dttime.csv
fi
done
cozsftp $ssh_opts -k $JES_SYSUID -b- $remoteuser@$server <<EOB
lzopts mode=text,servercp=ISO8859-1
cd $dir
put EM$emclnt.BillRpt.$dttime.csv
EOB
The following code splits the records by clients. I get the first two files in the the folder but not getting the last report since the $emclnt variable is not resolving to the correct client id.
What I am missing or what I have wrong in the code?
echo "$dir"
fromdsn -x shr //DD:FILE1 | while IFS=',' read v1 v2 v3 v4 v5 v6 v7 \
v8 v9 v10 V11
do
if test "$v1" = "EM_CLNT_ID"
then
header=`echo "$v1,$v2,$v3,$v4,$v5,$v6,$v7,$v8,$v9,$v10,$v11"`
echo "$header"
emclnt=$v1
elif test "$emclnt" = "EM_CLNT_ID"
then
dttime=`date "+%Y%m%d.%H%M%S"`
emclnt=$v1
echo "$header" >> EM$emclnt.BillRpt.$dttime.csv
echo "$v1,$v2,$v3,$v4,$v5,$v6,$v7,$v8,$v9,$v10,$v11" >> \
EM$emclnt.BillRpt.$dttime.csv
elif test "$emclnt" = "$v1"
then
echo "$v1,$v2,$v3,$v4,$v5,$v6,$v7,$v8,$v9,$v10,$v11" >> \
EM$emclnt.BillRpt.$dttime.csv
emclnt=$v1
elif test "$emclnt" != "$v1"
then
echo "$emclnt & $v1"
cozsftp $ssh_opts -k $JES_SYSUID -b- $remoteuser@$server <<EOF
lzopts mode=text,servercp=ISO8859-1
cd $dir
put EM$emclnt.BillRpt.$dttime.csv
EOF
emclnt="$v1"
echo "$header" >> EM$emclnt.BillRpt.$dttime.csv
echo "$v1,$v2,$v3,$v4,$v5,$v6,$v7,$v8,$v9,$v10,$v11" >> \
EM$emclnt.BillRpt.$dttime.csv
fi
done
cozsftp $ssh_opts -k $JES_SYSUID -b- $remoteuser@$server <<EOB
lzopts mode=text,servercp=ISO8859-1
cd $dir
put EM$emclnt.BillRpt.$dttime.csv
EOB