Running scripts on remote servers

Discussion of the COZBATCH utility for z/OS
Post Reply
gngrossi
Posts: 36
Joined: Sat Mar 06, 2010 6:10 pm

Running scripts on remote servers

Post by gngrossi »

What's the difference between these two examples besides being able to connect to multiple servers with COZBATCH? How can I use the saf-ssh-agent in the COZBATCH example?
Thanks.

COZ Launcher
//RUNCOZ EXEC PROC=COZL,ARGS='user@server1'
//COZCFG DD *
//STDIN DD *
hostname;uname -a
ps -ef | grep abc
sar

COZBATCH
//RUNCOZ EXEC PROC=COZB
//STDIN DD *
echo Test 1
cat << EOF | ssh user@server1 "bash -ls"
hostname;uname -a
ps -ef | grep abc
sar
EOF
echo Test 2
cat << EOF | ssh user@server2 "bash -ls"
hostname;uname -a
ps -ef | grep abc
sar
EOF
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

In your example, both do basically the same thing.
The big difference between using the Co:Z Launcher and just ssh is that with the Co:Z Launcher you can use the "todsn" and "fromdsn" commands running in the remote script to access datasets and DDs back in the launching job:

Code: Select all

//RUNCOZ EXEC PROC=COZL,ARGS='user@server1'
//COZCFG DD *
//STDIN DD *
hostname;uname -a
ps -ef | grep abc
fromdsn //HLQ.MY.DS | grep foo
//

To use the saf-ssh-agent with an ssh command:

Code: Select all

saf-ssh-agent -c MYRING ssh user@server1 cmd
The ssh command (or any command) is run as a child process of the saf-ssh-agent command with an ssh key agent configured in the environment.
gngrossi
Posts: 36
Joined: Sat Mar 06, 2010 6:10 pm

Post by gngrossi »

Adding saf-ssh-agent -c KEY works great.
Thanks.

cat << EOF | saf-ssh-agent -c KEY ssh user@server "bash -ls"
hostname;uname -a
ps -ef | grep abc
sar
EOF
Post Reply