Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Executing Linux Shell Script from Mainframe

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
yuvan

New User


Joined: 10 Jan 2006
Posts: 20
Location: India

PostPosted: Fri Jan 17, 2020 4:24 pm    Post subject: Executing Linux Shell Script from Mainframe
Reply with quote

Hi Team,

Is it possible to execute a Linux script through a mainframe job , We have installed the Coz SFTP installed in our mainframe and SSH also enabled.

I searched through , but could not find any , Please could you tell the possible options.
Back to top
View user's profile Send private message

vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1685
Location: Tiruppur, India

PostPosted: Sat Jan 18, 2020 12:31 am    Post subject:
Reply with quote

This approach does not use SFTP and I don't think SFTP can run scripts remotely.

Inorder to trigger a Linux script from Mainframe remotely, you would need to have established key based authentication between Mainframe and Linux system.
If you already have public and private keys setup and configured between the systems then its simple.
Code:
//RUNSHEL1 EXEC PGM=BPXBATCH                                           
//STDOUT   DD  SYSOUT=*                                               
//STDERR   DD  SYSOUT=*                                               
//STDPARM  DD  *                                                       
SH ssh -i /pathofkey/rsa_keyname userid@LINUX_IP 'sh -s' < /pathofscript/hello.sh
/*

or

SH ssh -i /pathofkey/rsa_keyname userid@LINUX_IP 'bash -s' < /pathofscript/hello.sh


Where
/pathofkey/rsa_keyname - This is Mainframe USS file location of the private key.
userid - UserID on the Linux machine
LINUX_IP - IP address or name of the linux machine
/pathofscript/hello.sh - This file is present in Mainframe and would be transmitted to the Linux machine and the script would run there.

If you don't have public private keys setup then I can go over it. But will wait for a response.
Back to top
View user's profile Send private message
yuvan

New User


Joined: 10 Jan 2006
Posts: 20
Location: India

PostPosted: Tue Jan 21, 2020 10:40 am    Post subject:
Reply with quote

Not sure SSH key based is setup now .

I just tried with the given JCLs in Dev region , but facing problem in where to add the Linux script /pathofscript/hello.sh .

Tried with the mainframe datasets ,but it says as below.

FSUM7343 cannot open "//XXX.TEST.XXX.JCLS/TESTX" for input: EDC5129I No such file or directory.

Please let us know how to setup if we do not have ssh keys not available.
Back to top
View user's profile Send private message
yuvan

New User


Joined: 10 Jan 2006
Posts: 20
Location: India

PostPosted: Tue Jan 21, 2020 4:29 pm    Post subject:
Reply with quote

Again , I tried with
SH ssh -i /abcusr1/laduser z-kcp-kad@159.15x.xxx.xx 'bash -s' <
/abcusr1/laduser/test.sh

it says

FSUM7343 cannot open "/abcusr1/laduser/test.sh" for input:: EDC5111I Permission denied.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 733
Location: Pennsylvania

PostPosted: Tue Jan 21, 2020 6:17 pm    Post subject:
Reply with quote

Hello,

The same company that provides Coz SFTP has a product that may be able to do what you need.

//dovetail.com/products/hybridbatch.html

We successfully used this to execute Mainframe SAS programs on Unix servers.

It took us a great deal of time and effort to get it working properly, so I can not just say 'here you go' this is how you should do it.

You will need to contact the company for guidance.

Please note, we 'pay' the company for support. Do not expect them to be diligent with you for free.

I am just directing you to a possible solution.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1685
Location: Tiruppur, India

PostPosted: Wed Jan 22, 2020 4:29 am    Post subject:
Reply with quote

Code:
FSUM7343 cannot open "/abcusr1/laduser/test.sh" for input:: EDC5111I Permission denied.


This says you don't have access to this file. Check the unix file permissions for that file
Back to top
View user's profile Send private message
yuvan

New User


Joined: 10 Jan 2006
Posts: 20
Location: India

PostPosted: Wed Jan 22, 2020 10:29 am    Post subject:
Reply with quote

Now getting below message.

FOTS1273 Warning: Identity file /abcusr1/laduser not accessible: EDC5121I Invalid argument. (errno2=0x055B005B).


FOTS1346 Permission denied, please try again.
FOTS1346 Permission denied, please try again.
FOTS1373 Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).



Actual JCL

//RUNSHEL1 EXEC PGM=BPXBATCH
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDPARM DD *
SH ssh -i /abcusr1/laduser z-kvc-dev@158.xxx.xxx.xx 'sh -s' <
/abcusr1/test.sh
/*
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1685
Location: Tiruppur, India

PostPosted: Wed Jan 22, 2020 11:30 pm    Post subject:
Reply with quote

Hello,

Code:
FOTS1273 Warning: Identity file /abcusr1/laduser not accessible: EDC5121I Invalid argument. (errno2=0x055B005B).

In your JCL it points to a directory and not a private key file hence the error.

SH ssh -i /pathofkey/rsa_keyname userid@LINUX_IP 'sh -s' < /pathofscript/hello.sh
The text in red above needs to point to a file(not a directory). The file is supposed to contain a private key.

Private key is something that looks like
Code:
-----BEGIN RSA PRIVATE KEY-----                                 
sdfsdfdsfteraj63WF3Jy0CvUsY6mfRqjP53HuRLe5PElFAbQbUcg
MUOcMeZiFxH+K54ZOcxiagcM+h4hjkswdeyZBpxq9mN2YPwd11ddsfsdfsdfY
.
.
.
-----END RSA PRIVATE KEY-----

The private key needs to have a permission of 600. And owned by the user initiating the SSH.

You need to take help from a Unix programmer and Mainframe systems programmer to set the keys up. It would be really hard to set it up without their help.

We members of the forum are happy to help you if you encounter more errors Or if you want to take the easy route, I am up for hire at $100 for the whole setup.
Back to top
View user's profile Send private message
yuvan

New User


Joined: 10 Jan 2006
Posts: 20
Location: India

PostPosted: Mon Jan 27, 2020 11:54 am    Post subject: Reply to: Executing Linux Shell Script from Mainframe
Reply with quote

Hi , I am able to run a script with the below option .

//RUNCOZ EXEC PROC=COZPROC,ARGS='unixuserid@111.222.333.4444'
//COZCFGD DD *
//STDIN DD *
uname -norm
date
uptime
pwd
~/scripts/do-tmp-stuff.sh
date
/*
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1685
Location: Tiruppur, India

PostPosted: Tue Jan 28, 2020 2:29 am    Post subject:
Reply with quote

Thanks for posting the solution.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Mainframe Storage HSM upendrasri IBM Tools 5 Thu Feb 20, 2020 5:51 pm
No new posts doubt when executing a file when logg... Renato Zangerolami TSO/ISPF 2 Fri Feb 07, 2020 6:07 pm
No new posts mainframe ps file to unix box alpit All Other Mainframe Topics 4 Fri Feb 07, 2020 11:19 am
No new posts SFTP from Linux to Mainframe yuvan All Other Mainframe Topics 4 Fri Jan 10, 2020 4:44 pm
No new posts FTP to SFTP for JCL submission from M... yuvan All Other Mainframe Topics 1 Tue Dec 31, 2019 12:22 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us