Automating Mainframe requests

Download VSCode

https://code.visualstudio.com/Download

Download git bash

Windows:

https://git-scm.com/download/win

MAC OS

You need to install brew, once that's done run

$ brew install git

If you have linux then you dont have to install anything for bash commands.

Theres nothing special for installation so keep on clicking next until you finish.

This is what it looks like, there will be different things installed but you only need git bash.

By default you are in the home or ~

Open up nano and copy and paste this into the text editor.

USER=

PASSWORD=

ASMCWD=$(dirname $1)

echo [$ASMCWD]

echo Logging in and starting job...

ftp -nv zos.kctr.marist.edu > $ASMCWD/out <

user $USER $PASSWORD

quote site filetype=jes

put $1

quit

EOF

JOB=$(cat $ASMCWD/out | grep -oP '(JOB[0-9])\w+' | head -1)

if [ -z "$JOB" ]

then

echo "Something terrible went wrong, and the job wasn't sumbitted right."

exit

else

echo Job created! ID is $JOB

fi

sleep 2

ftp -nv zos.kctr.marist.edu >> $ASMCWD/out << EOF

user $USER $PASSWORD

quote site filetype=jes

get $JOB

delete $JOB

quit

EOF

#cat $JOB

mv $JOB $ASMCWD/$JOB

cat $ASMCWD/$JOB > $1.txt

rm $ASMCWD/$JOB

rm $ASMCWD/out

echo Done.

*if youre using linux then you need the -p flag to the ftp command, so its ftp -nvp*

You can call the file whatever you want, but heres an example name.

Submit.sh

If you dont know nano or vi, its ctrl + o to save and ctrl + x to quit.

In vi its shift + ZZ to save and quit.

Heres a GET script to get members in your PDSE.

Example name: get.sh

USER=

PASSWORD=

echo Logging in and getting file

DATASET="'*KC-ID*.csci360.assigns($1)'"

ftp -nv zos.kctr.marist.edu << EOF

user $USER $PASSWORD

get $DATASET

quit

EOF

cat $DATASET > $1.asm

rm $DATASET

*same as above, enter your credentials and replace *KC-ID* with your KC-ID

Ex. DATASET="'KC03IA2.csci360.assigns($1)'"

Or if youre in 465....

Ex. DATASET="'KC03IA2.csci465.assigns($1)'"

*same as above, linux users add the -p flag*

Feel free to change .asm to .jcl or .cob depending on your work.

cat $DATASET > $1.asm OR cat $DATASET > $1.jcl OR cat $DATASET > $1.cob

We want the .asm extension for those in 360 as vscode will immediately detect and initiate the syntax highlighting for assembler.

Finally heres the script to put whatever you have in your machine to the mainframe.

Example name: put.sh

USER=

PASSWORD=

echo Logging in and getting file

DATASET="'*KC-ID*.csci360.assigns'"

ftp -nv zos.kctr.marist.edu << EOF

user $USER $PASSWORD

cd $DATASET

put $1

quit

EOF

*same as above, replace the *kc-id* with yours and linux users add -p*

Finally, we need to give the files execution permission.

chmod +x submit.sh get.sh put.sh

Example run:

Lets say you already have a member called ASSIGN1. Open up the terminal with ctrl + shift + ~ or however you normally do.

Then type

./get.sh ASSIGN1

The file will be in the same directory as the script.

Now what if we want to run it?

Then type

./submit.sh ASSIGN1.asm

Our output is the .txt file

We can switch between tabs using ctrl + pageup or pagedown

Now everytime you submit the job, you will have your newest submission.

If you ever need the professor or your TA to look at your work, then run

./put.sh ASSIGN1

As an example, this will put your work in your PDS.

Extensions?

With these extensions you will have autocompletion, syntax highlighting.

.jcl for those in 465 and then you can enable the cobol intellisense by going on the bottom right hand corner.