From: e p chandler on 16 Dec 2009 11:58 On Dec 16, 3:10 am, gaya3 <gayathri.kalyanasunda...(a)wipro.com> wrote: > On Dec 15, 11:23 pm, Richard <rip...(a)Azonic.co.nz> wrote: > > > > > > > On Dec 16, 4:25 pm, gaya3 <gayathri.kalyanasunda...(a)wipro.com> wrote: > > > > On Dec 15, 12:29 pm, Richard <rip...(a)Azonic.co.nz> wrote: > > > > > On Dec 16, 1:09 am, gaya3 <gayathri.kalyanasunda...(a)wipro.com> wrote: > > > > > > Hi, > > > > > > Is there any way to call a AIX shell script from IBM AIX COBOL? Could > > > > > someone give me the link to the syntax/examples? Also, Is there a way > > > > > to call system commands like "Echo 123" etc. using COBOL. > > > > > > It would be very helpful for me if syntax/examples are provided. > > > > > It is possible that you could do this via a > > > > > CALL "system" USING "sh scriptname" & x"00" > > > > > or something similar, but this will depend on the implementation of > > > > the compiler and I am unfamiliar with that one. > > > > Nopes.. This is not any kind of assignment.. I know that we can invoke > > > system commands using C / C++. When i searched the internet, i could > > > not find anything similar for COBOL. Ofcourse, there are pages where > > > COBOL calls C/C++ and C/C++ intern invoke system commands. I dont want > > > to do that. Let us say, i want to extract the uid using aix ibm cobol > > > code. How to do this? One more thing, I did search a lot for the > > > solution and am coming to this forum as the last resort. Also, I tried > > > using CALL "system" ... The said command is applicable only for MF > > > cobol and not for IBM AIX cobol. Please correct if wrong and also, > > > please let me know how to call system commands from cobol code. It > > > must be possible to call shell scripts from cobol. I just want to know > > > how it is done! > > > You asked how to "call a AIX shell script". The way this is done in C > > is via a "system(scriptcommand);" subroutine call. > > > system() is a standard C library routine. The special MF call is CALL > > "SYSTEM". Note that this is upper case. The lower case version CALL > > "system" should use the standard C library. > > > That you find it does not work could be caused by one of several > > reasons, such as it is trying to do a dynamic call, or has been > > remapped to upper-case, or you haven't supplied the C library. If you > > can call C then you should be able to call C's library routines.- Hide quoted text - > > > - Show quoted text - > > On Dec 15, 11:23 pm, Richard <rip...(a)Azonic.co.nz> wrote: > > > > > > > On Dec 16, 4:25 pm, gaya3 <gayathri.kalyanasunda...(a)wipro.com> wrote: > > > > On Dec 15, 12:29 pm, Richard <rip...(a)Azonic.co.nz> wrote: > > > > > On Dec 16, 1:09 am, gaya3 <gayathri.kalyanasunda...(a)wipro.com> wrote: > > > > > > Hi, > > > > > > Is there any way to call a AIX shell script from IBM AIX COBOL? Could > > > > > someone give me the link to the syntax/examples? Also, Is there a way > > > > > to call system commands like "Echo 123" etc. using COBOL. > > > > > > It would be very helpful for me if syntax/examples are provided. > > > > > It is possible that you could do this via a > > > > > CALL "system" USING "sh scriptname" & x"00" > > > > > or something similar, but this will depend on the implementation of > > > > the compiler and I am unfamiliar with that one. > > > > Nopes.. This is not any kind of assignment.. I know that we can invoke > > > system commands using C / C++. When i searched the internet, i could > > > not find anything similar for COBOL. Ofcourse, there are pages where > > > COBOL calls C/C++ and C/C++ intern invoke system commands. I dont want > > > to do that. Let us say, i want to extract the uid using aix ibm cobol > > > code. How to do this? One more thing, I did search a lot for the > > > solution and am coming to this forum as the last resort. Also, I tried > > > using CALL "system" ... The said command is applicable only for MF > > > cobol and not for IBM AIX cobol. Please correct if wrong and also, > > > please let me know how to call system commands from cobol code. It > > > must be possible to call shell scripts from cobol. I just want to know > > > how it is done! > > > You asked how to "call a AIX shell script". The way this is done in C > > is via a "system(scriptcommand);" subroutine call. > > > system() is a standard C library routine. The special MF call is CALL > > "SYSTEM". Note that this is upper case. The lower case version CALL > > "system" should use the standard C library. > > > That you find it does not work could be caused by one of several > > reasons, such as it is trying to do a dynamic call, or has been > > remapped to upper-case, or you haven't supplied the C library. If you > > can call C then you should be able to call C's library routines.- Hide quoted text - > > > - Show quoted text - > > Thank you for the reply! > I have posted the code that i tried and also the error. > ======================================================== > * > Identification Division. > Program-Id. SysCmds. > > Data Division. > Working-storage Section. > 01 cmd-line pic x(3) value "sh". > 01 cmd-line2 pic x(30) value "cp f1 f2 >errfile 2>&1". > > procedure division. > display "Test" > call "SYSTEM" using cmd-line > display "Back in program" > call "SYSTEM" using cmd-line2 > display "Back in program" > stop run. > ============================================================== > > Error during the execution of the code: > ~> cob2 try1.cbl > IBM COBOL for AIX 2.0.0 in progress ... > End of compilation 1, program SYSCMDS, no statements flagged. > ld: 0711-317 ERROR: Undefined symbol: .SYSTEM > NO NO NO! This is not a run time error. You compiled the code but it failed to link. ld is the system linker. As the error message says .SYSTEM is an undefined symbol. That means one of several things. 1. Perhaps you should have tried CALL "system" instead. 2. I suspect that the Cobol compiler upper cases symbols unless you insert a compiler directive for mixed case. See the Programmer's manual. 3. You may have to include the name of the program library that contains the C routine on your command line. [see any *nix text for details] > ============================================================= > > As i understand from the above code, the IBM AIX cobol doesnt use > SYSTEM command. Is there any other possibility. Or, Can the scripts be > called only from C/C++ programs! I dont think the latter would be the > case. There should be some way to call scripts directly from ibm aix > cobol when there is a way in MF cobol!!!Am i doing something wrong > here? NO. Just because vendor A does something does not mean that vendor B has to do it as well (unless perhaps A is IBM .... smile). Shelling out from a Cobol program is not mandated by any Cobol language standard. It is not portable. You get what you get. Based on what you have posted I suggest that you look for alternatives in the realm of shell scripting before you attempt either mixed language programming or writing a C/C++ wrapper around the system routine.
From: Richard on 16 Dec 2009 12:38 On Dec 16, 9:10 pm, gaya3 <gayathri.kalyanasunda...(a)wipro.com> wrote: > On Dec 15, 11:23 pm, Richard <rip...(a)Azonic.co.nz> wrote: > > > > > On Dec 16, 4:25 pm, gaya3 <gayathri.kalyanasunda...(a)wipro.com> wrote: > > > > On Dec 15, 12:29 pm, Richard <rip...(a)Azonic.co.nz> wrote: > > > > > On Dec 16, 1:09 am, gaya3 <gayathri.kalyanasunda...(a)wipro.com> wrote: > > > > > > Hi, > > > > > > Is there any way to call a AIX shell script from IBM AIX COBOL? Could > > > > > someone give me the link to the syntax/examples? Also, Is there a way > > > > > to call system commands like "Echo 123" etc. using COBOL. > > > > > > It would be very helpful for me if syntax/examples are provided. > > > > > It is possible that you could do this via a > > > > > CALL "system" USING "sh scriptname" & x"00" > > > > > or something similar, but this will depend on the implementation of > > > > the compiler and I am unfamiliar with that one. > > > > Nopes.. This is not any kind of assignment.. I know that we can invoke > > > system commands using C / C++. When i searched the internet, i could > > > not find anything similar for COBOL. Ofcourse, there are pages where > > > COBOL calls C/C++ and C/C++ intern invoke system commands. I dont want > > > to do that. Let us say, i want to extract the uid using aix ibm cobol > > > code. How to do this? One more thing, I did search a lot for the > > > solution and am coming to this forum as the last resort. Also, I tried > > > using CALL "system" ... The said command is applicable only for MF > > > cobol and not for IBM AIX cobol. Please correct if wrong and also, > > > please let me know how to call system commands from cobol code. It > > > must be possible to call shell scripts from cobol. I just want to know > > > how it is done! > > > You asked how to "call a AIX shell script". The way this is done in C > > is via a "system(scriptcommand);" subroutine call. > > > system() is a standard C library routine. The special MF call is CALL > > "SYSTEM". Note that this is upper case. The lower case version CALL > > "system" should use the standard C library. > > > That you find it does not work could be caused by one of several > > reasons, such as it is trying to do a dynamic call, or has been > > remapped to upper-case, or you haven't supplied the C library. If you > > can call C then you should be able to call C's library routines.- Hide quoted text - > > > - Show quoted text - > > On Dec 15, 11:23 pm, Richard <rip...(a)Azonic.co.nz> wrote: > > > > > On Dec 16, 4:25 pm, gaya3 <gayathri.kalyanasunda...(a)wipro.com> wrote: > > > > On Dec 15, 12:29 pm, Richard <rip...(a)Azonic.co.nz> wrote: > > > > > On Dec 16, 1:09 am, gaya3 <gayathri.kalyanasunda...(a)wipro.com> wrote: > > > > > > Hi, > > > > > > Is there any way to call a AIX shell script from IBM AIX COBOL? Could > > > > > someone give me the link to the syntax/examples? Also, Is there a way > > > > > to call system commands like "Echo 123" etc. using COBOL. > > > > > > It would be very helpful for me if syntax/examples are provided. > > > > > It is possible that you could do this via a > > > > > CALL "system" USING "sh scriptname" & x"00" > > > > > or something similar, but this will depend on the implementation of > > > > the compiler and I am unfamiliar with that one. > > > > Nopes.. This is not any kind of assignment.. I know that we can invoke > > > system commands using C / C++. When i searched the internet, i could > > > not find anything similar for COBOL. Ofcourse, there are pages where > > > COBOL calls C/C++ and C/C++ intern invoke system commands. I dont want > > > to do that. Let us say, i want to extract the uid using aix ibm cobol > > > code. How to do this? One more thing, I did search a lot for the > > > solution and am coming to this forum as the last resort. Also, I tried > > > using CALL "system" ... The said command is applicable only for MF > > > cobol and not for IBM AIX cobol. Please correct if wrong and also, > > > please let me know how to call system commands from cobol code. It > > > must be possible to call shell scripts from cobol. I just want to know > > > how it is done! > > > You asked how to "call a AIX shell script". The way this is done in C > > is via a "system(scriptcommand);" subroutine call. > > > system() is a standard C library routine. The special MF call is CALL > > "SYSTEM". Note that this is upper case. The lower case version CALL > > "system" should use the standard C library. > > > That you find it does not work could be caused by one of several > > reasons, such as it is trying to do a dynamic call, or has been > > remapped to upper-case, or you haven't supplied the C library. If you > > can call C then you should be able to call C's library routines.- Hide quoted text - > > > - Show quoted text - > > Thank you for the reply! > I have posted the code that i tried and also the error. > ======================================================== > * > Identification Division. > Program-Id. SysCmds. > > Data Division. > Working-storage Section. > 01 cmd-line pic x(3) value "sh". > 01 cmd-line2 pic x(30) value "cp f1 f2 >errfile 2>&1". > > procedure division. > display "Test" > call "SYSTEM" using cmd-line > display "Back in program" > call "SYSTEM" using cmd-line2 > display "Back in program" > stop run. > ============================================================== > > Error during the execution of the code: > ~> cob2 try1.cbl > IBM COBOL for AIX 2.0.0 in progress ... > End of compilation 1, program SYSCMDS, no statements flagged. > ld: 0711-317 ERROR: Undefined symbol: .SYSTEM > As already pointed out the 'ld' linker command could not find 'SYSTEM' in the list of libraries that it searched. I have already told you that the correct name for the C library routine is "system" in lower case. You will also need to null terminate the parameter to the call. I had indicated this with '& x"00"'. You may need to use LOW-VALUES or some other to get a null into the string, such as: MOVE LOW-VALUE TO cmd-line(3:1) > ============================================================= > > As i understand from the above code, the IBM AIX cobol doesnt use > SYSTEM command. Is there any other possibility. Or, Can the scripts be > called only from C/C++ programs! I dont think the latter would be the > case. There should be some way to call scripts directly from ibm aix > cobol when there is a way in MF cobol!!!Am i doing something wrong > here? Yes. You are not listening.
From: Anonymous on 16 Dec 2009 14:45 In article <573b5fec-d9b2-45d6-bf4f-9be02aff5c63(a)g25g2000vbl.googlegroups.com>, Alistair <alistair(a)ld50macca.demon.co.uk> wrote: >On Dec 15, 2:06?pm, docdw...(a)panix.com () wrote: >> In article <42898ffb-c829-489a-b366-18aec7e0d...(a)1g2000vbm.googlegroups.com>, >> >> gaya3 ?<gayathri.kalyanasunda...(a)wipro.com> wrote: >> >Hi, >> >> >Is there any way to call a AIX shell script from IBM AIX COBOL? >> >> This 'smells' like homework/'do my job for me' but I'll follow up, >> anyhow. ? >> > >Smells like?! Are you going soft in your dotage? Softlty, Mr Maclean, and recall that ye might find yourself close enough to a rolling-chair to be whacked upon the noggin with a walking-stick... and don't get me started on what these youngsters are callin' 'music' nowadays, neither. (a change in tactics can throw someone off-balance... or so I once read written on a strip of paper inside a cookie) DD
From: Pete Dashwood on 16 Dec 2009 17:10 Louis Krupp wrote: > gaya3 wrote: > <snip> >> As i understand from the above code, the IBM AIX cobol doesnt use >> SYSTEM command. Is there any other possibility. Or, Can the scripts >> be called only from C/C++ programs! I dont think the latter would be >> the case. There should be some way to call scripts directly from ibm >> aix cobol when there is a way in MF cobol!!!Am i doing something >> wrong here? > > Yes. You're assuming that because you would like AIX COBOL to have > "call system" or its equivalent, it must have one. It's OK; wishful > thinking is human nature. > > I looked at the AIX COBOL manual online (as I assume you did), and I > couldn't find anything. There are examples of AIX COBOL calling C > functions, and at this point, I think you should probably do that. Pleased to hear you say that Louis. :-) I hate things that "can't be done" so I too went and looked at the manual online ... :-) I couldn't find anything either. I suspect the User's guide might be more helpful. I DID find that AIX COBOL has support for OOP and the manual is well laid out. I also found an IBM site that gives support to AIX programmers... I didn't keep the link but I'm sure if the OP invests some time in doing the same searches you and I did, he'll probably find it. (On reading the above, I realised it seems a bit churlish and unhelpful, so I took a minute to go and find it again.... here it is: http://www-01.ibm.com/software/awdtools/cobol/aix/support/ ) Pete. -- "I used to write COBOL...now I can do anything."
From: gaya3 on 17 Dec 2009 04:16 On Dec 16, 5:10 pm, "Pete Dashwood" <dashw...(a)removethis.enternet.co.nz> wrote: > Louis Krupp wrote: > > gaya3 wrote: > > <snip> > >> As i understand from the above code, the IBM AIX cobol doesnt use > >> SYSTEM command. Is there any other possibility. Or, Can the scripts > >> be called only from C/C++ programs! I dont think the latter would be > >> the case. There should be some way to call scripts directly from ibm > >> aix cobol when there is a way in MF cobol!!!Am i doing something > >> wrong here? > > > Yes. You're assuming that because you would like AIX COBOL to have > > "call system" or its equivalent, it must have one. It's OK; wishful > > thinking is human nature. > > > I looked at the AIX COBOL manual online (as I assume you did), and I > > couldn't find anything. There are examples of AIX COBOL calling C > > functions, and at this point, I think you should probably do that. > > Pleased to hear you say that Louis. :-) > > I hate things that "can't be done" so I too went and looked at the manual > online ... :-) > > I couldn't find anything either. I suspect the User's guide might be more > helpful. > > I DID find that AIX COBOL has support for OOP and the manual is well laid > out. > > I also found an IBM site that gives support to AIX programmers... I didn't > keep the link but I'm sure if the OP invests some time in doing the same > searches you and I did, he'll probably find it. > > (On reading the above, I realised it seems a bit churlish and unhelpful, so > I took a minute to go and find it again.... here it is:http://www-01.ibm.com/software/awdtools/cobol/aix/support/) > > Pete. > -- > "I used to write COBOL...now I can do anything."- Hide quoted text - > > - Show quoted text - Thank you Louis Krupp & Peter Dashwood and thanks a lot to everyone answered.. I guess the only way to call the c functions..! I went ahead with c system command and the code worked.. Yes, though it would have been nice to have a cobol code with built in functionalities though..:) that can call scripts and commands! Thank you everybody!
First
|
Prev
|
Pages: 1 2 3 Prev: License Management Service Next: Climate models suck - It's the programming |