Can a shell variable be called in a cobol program


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can a shell variable be called in a cobol program
# 1  
Old 10-21-2011
Question Can a shell variable be called in a cobol program

Hi All,
I have a file which sets all the variables on unix , based on the hostname. Currently these variables are hardcoded in the cobol programs.I was wondering if unix variables can be used in Cobol programs ?

Example :
I have a variable $SHTEMP which is set based on the following :

Prod server : /lv8/pearl/shprod/shtemp

Test Server : /lv8/pearl/shtest/shtemp

Can I use $SHTEMP variable in the cobol program ?

Any help would be appreciated.
# 2  
Old 10-21-2011
If you exported it as an environment variable perhaps, before running the program.

Code:
SHTEMP="..."
export SHTEMP

myprogram

How to retrieve it depends on what cobol compiler/toolset you're using.
# 3  
Old 10-21-2011
Isn't it an option to you, instead of acessing an environment variable from inside COBOL, receive it as an argument to your program?

I don't know a lot about COBOL, I used microfocus a few times and below is a part of one of my programs that received an argument - PROCEDURE DIVISION:
Code:
	GET-CMDLINE-ARG.
		ACCEPT PRG-ARGS FROM COMMAND-LINE.
		ACCEPT COUNT-ARGS FROM ARGUMENT-NUMBER.
		DISPLAY "INF: Count arguments  : [", COUNT-ARGS, "]".
		DISPLAY "INF: Program arguments: [", PRG-ARGS, "]".

Hope it helps!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to pass the config file lines as variable on the respective called function on a script

I want to make a config file which contain all the paths. i want to read the config file line by line and pass as an argument on my below function. Replace all the path with reading config path line by line and pass in respective functions. how can i achieve that? Kindly guide. ... (6 Replies)
Discussion started by: sadique.manzar
6 Replies

2. UNIX for Dummies Questions & Answers

shell program- how many times a function is called

We have a program source C and is required to indicate how many times each function is called from the C program. also print the line number where there is a call. I've tried something like this: #!/bin/sh for i in $*;do if ! then echo $i is not a C file. else echo $i... (0 Replies)
Discussion started by: oana06
0 Replies

3. Shell Programming and Scripting

Shell variable to c++ program as input

I have an Shell script which has few global variables eg : range=100; echo "$range" I want to use the same variable in my C++ program for example int main() { cout << range << "\n"; } i tried using this int main(int argc, char *argv) { cout << range << "\n"; } but... (5 Replies)
Discussion started by: shashi792
5 Replies

4. UNIX for Dummies Questions & Answers

How to retrieve the value of variable in shell script which is called by crontab

There are two files one is shell script (sample.sh) and another is configuration file (sampl_conf.cfg) configuration file contains one variable $FTP_HOME. the value of this variable vaires for user to user. If user is say jadoo then value is /home/jadoo/ftp/, for user1 - /home/user1/ftp. The... (4 Replies)
Discussion started by: jadoo_c2
4 Replies

5. Shell Programming and Scripting

environment variable in shell script called through crontab

Please help me on below.. https://www.unix.com/shell-programming-scripting/141533-retrieve-value-environment-variable-shell-script-called-crontab.html#post302442024 I'm still here. I can still see you! (0 Replies)
Discussion started by: jadoo_c2
0 Replies

6. Shell Programming and Scripting

Retrieve the value of environment variable in shell script which called from crontab

There are two files one is shell script (sample.sh) and another is configuration file (sampl_conf.cfg) configuration file contains one variable $FTP_HOME. the value of this variable vaires for user to user. If user is say jadoo then value is /home/jadoo/ftp/, for user1 - /home/user1/ftp. The... (0 Replies)
Discussion started by: jadoo_c2
0 Replies

7. Programming

Seg Fault Running AIX COBOL program

Hi some help read............ I'm getting a segmentation fault when I run an AIX COBOL/Db2 program. I initiate the program from the command line, but it hangs, and then when I press enter it generates a segmantation fault and produces a core dump. The box is running AIX software level ... (5 Replies)
Discussion started by: steve_f
5 Replies

8. Programming

cobol crn programme run on express cobol as .gnt

can i run .crn programme in express cobol which support to .gnt programme .... Plz tell me solution (2 Replies)
Discussion started by: bibi
2 Replies

9. Programming

How to debug with wdb debugger a cobol program?

Hi Forum, i have such a question. I have a cobol program which is calling a C program and in that C program i get a core dump:(. I want to investigate what is the issue using WDB debuger, but a dont see the code from COBOL program in the debuger, when i run the debugger with the exe!!! ... (2 Replies)
Discussion started by: vovan
2 Replies

10. Shell Programming and Scripting

pass arguments to called program

Thank you very much. (2 Replies)
Discussion started by: ShellUser
2 Replies
Login or Register to Ask a Question