View previous topic :: View next topic
|
Author |
Message |
sabav42
New User
Joined: 09 Jun 2014 Posts: 5 Location: India
|
|
|
|
Hi All,
I would like to know how to execute C program in Mainframe.
Please help me.
Advance Thanks for your sharing. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
//stepname EXEC PGM=yourCprogram |
If you need something else, first ask how it is done at your site. Is this part of a competition? |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
You did not tell us whether you really meant, "How do I compile and execute a C program on the mainframe?" or "How do I execute the binary program prepared by compiling a C program?"
Mr. Woodger answered the second question, at least in part. The answer for the first question is more complex. A forum such as this is not a good source for this type of query. It depends on the exact version of the C compiler used on the mainframe you are using and other conventions established for that mainframe. You should ask this question of the support organization for that mainframe.
Another question you did not ask is "How do I specify files for C functions like fopen?"
Going back to the second question in the first paragraph, you did not tell us the environment you expect to use when executing the prgram. There are four possible environments:- Batch from JCL
- TSO command line
- ISPF
- The Unix like command environment within TSO
|
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
Man..that sounded like such a simple question when I read it, but these guys are correct. There is much more to it.
Let me tell you how I did it, years ago, under MVS.
You know how you have to compile a COBOL program to make it work? You have to do the same with a C program. In my shop, everyone pretty much uses batch jobs to compile COBOL programs. I poked around and found the libraries where the JCL was stored, then found the C versions of the compilers in that library.
I spent like a week getting the JCL fixed up to point to the needed libraries, have the correct compile options, and produce a usable load module.
Then, I created some execution JCL that needed to have the right system libraries in the STEPLIB.
This was a fun side project for me, and I got to learn about some of the lesser used parts of the shop's mainframe. If I had to do it for real, I would have started by asking my tech support folks where to get the approved compile JCL, or what on-line panel to use to create it. |
|
Back to top |
|
|
sabav42
New User
Joined: 09 Jun 2014 Posts: 5 Location: India
|
|
|
|
Yes.. I would like to excute the program in Batch from JCL environment.
As Ed Goodman said, i need to know the library details. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
sabav42 wrote: |
As Ed Goodman said, i need to know the library details. |
If this is what you are looking forward to then you should be talking to someone at your shop ,no one here can really help you with names at your site. |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
sabav42 wrote: |
Yes.. I would like to excute the program in Batch from JCL environment. ... |
OK. Batch JCL.
It's not widely appreciated, but
// EXEC PGM=xxx,PARM='a b c'
is roughly equivalent to using
xxx a b c
in a command line, and a C program can retrieve the text strings in the PARM text just like they would be retrieved from the command line in Windows or *NIX.
Just like any other batch program, you need a //STEPLIB DD statement or a //JOBLIB DD statement to specify the library where the compiled binary program is stored, and any other libraries needed to run your program.
The fopen function will use dynamic allocation if you specify fopen("data set name",...), or fopen will defer to a DD statement if it encounters fopen("dd:dd name",...). The I/O functions like gets and fgets map MVS data sets to Windows or *NIX "flat" files quite well. You can use MVS VSAM files, though I'm not familiar with the details.
This is about as much information as you can get in a public forum like this. For details in your mainframe environment you really need to consult with the support structure for your environment. Good luck. |
|
Back to top |
|
|
|