Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

MF COBOL and SMTP mail
Hi,

Can a MicroFocus COBOL (Server Express 2.2) program issue a Unix
(Solaris 9) system command and get back a return code in a similar way
to the C system() function?

Thanks,
Damien.

Report this thread to moderator Post Follow-up to this message
Old Post
Damien Mulcahy
10-02-04 08:55 PM


Re: MF COBOL and SMTP mail
On 1 Oct 2004 05:12:47 -0700, dmulcahy@revenue.ie (Damien Mulcahy)
wrote:

>Hi,
>
>Can a MicroFocus COBOL (Server Express 2.2) program issue a Unix
>(Solaris 9) system command and get back a return code in a similar way
>to the C system() function?

Yes. Say call 'system' using string.

If you have Oracle, look into its 'utl_smtp' library. It's faster than
spawning a shell.

Report this thread to moderator Post Follow-up to this message
Old Post
Robert Wagner
10-02-04 08:55 PM


Re: MF COBOL and SMTP mail
In article <6rmql05i5k808rsdq0usj7943g2bqq4983@4ax.com>, Robert Wagner <robert@wagner.net.y
ourmammaharvests> writes:
> On 1 Oct 2004 05:12:47 -0700, dmulcahy@revenue.ie (Damien Mulcahy)
> wrote:
> 
>
> Yes. Say call 'system' using string.

That generally does what the user expects, but with Server Express,
it's better to use the SX "SYSTEM" function, which handles things
like sanitizing the tty mode.  See MF KB article 17587.  (The SYSTEM
library routine is mysteriously missing from the SX documentation; I
used to use the C library system function myself until someone else
here told me about SYSTEM.)

However, Damien should note that the C system function does not
necessarily return the exit code of the process, and so neither
does the SX SYSTEM function.  (See the documentation of the system
function for details.)

--
Michael Wojcik                  michael.wojcik@microfocus.com

We are subdued to what we work in.  (E M Forster)

Report this thread to moderator Post Follow-up to this message
Old Post
Michael Wojcik
10-02-04 08:55 PM


Re: MF COBOL and SMTP mail
dmulcahy@revenue.ie (Damien Mulcahy) wrote

> Can a MicroFocus COBOL (Server Express 2.2) program issue a Unix
> (Solaris 9) system command and get back a return code in a similar way
> to the C system() function?

Yes, you should be able to get _a_ return with:

CALL "system"
using command-string
returning return-value

My reading of system() is that the return value is
'implementation-defined'.

The actual value will be 'a similar way', but may be a different value
depending on how the call has been implemented. It may also depend on
whether you are using .int which won't call the C library directly, or
.gnt which might.

MicroFoucus suggests that CALL "SYSTEM" (upper case) is preferable for
several reasons, mostly because it allows Cobol to reset the
environment such as the terminal parameters and this doesn't specify a
return value (at least in the documentation that I have).

Report this thread to moderator Post Follow-up to this message
Old Post
Richard
10-02-04 08:55 PM


Re: MF COBOL and SMTP mail
Robert Wagner <robert@wagner.net.yourmammaharvests> wrote
 
>
> Yes. Say call 'system' using string.
>
> If you have Oracle, look into its 'utl_smtp' library. It's faster than
> spawning a shell.

It worries me, Robert.  You claim to be a programmer and criticise
users for not telling you what they want and then you frequently
completely miss the point:

>and get back a return code in a similar way to the C system()
function?

You may be in a good position to give an actual answer and yet you
completely fail to read the question, preferring to add useless,
extraneous details about non-Cobol.

Under Solaris do you get a return code from CALL "system" ...
returning ?
Under Solaris with the same command string is it the same return as C
gives ?
Under Solaris is the return code from C's system() meaningful at all ?

Report this thread to moderator Post Follow-up to this message
Old Post
Richard
10-02-04 08:55 PM


Re: MF COBOL and SMTP mail
On 1 Oct 2004 15:27:14 -0700, riplin@Azonic.co.nz (Richard) wrote:

>Robert Wagner <robert@wagner.net.yourmammaharvests> wrote
> 
>
>It worries me, Robert.  You claim to be a programmer and criticise
>users for not telling you what they want and then you frequently
>completely miss the point:
> 
>function?
>
>You may be in a good position to give an actual answer and yet you
>completely fail to read the question, preferring to add useless,
>extraneous details about non-Cobol.
>
>Under Solaris do you get a return code from CALL "system" ...
>returning ?

The question was "get back a return code in a similar way to the C
system() function?" Call 'system' is _using_ the C function, so it
gets back EXACTLY the same as the C system() function.

>Under Solaris with the same command string is it the same return as C
>gives ?

Yes. Exactly the same.

>Under Solaris is the return code from C's system() meaningful at all ?

That's a long debate. For simple commands, it is.


Report this thread to moderator Post Follow-up to this message
Old Post
Robert Wagner
10-02-04 08:55 PM


Re: MF COBOL and SMTP mail
On 1 Oct 2004 15:19:36 -0700, riplin@Azonic.co.nz (Richard) wrote:

>dmulcahy@revenue.ie (Damien Mulcahy) wrote
> 
>
>Yes, you should be able to get _a_ return with:
>
>    CALL "system"
>        using command-string
>        returning return-value

Lacking returning, it will be in RETURN-CODE.

>MicroFoucus suggests that CALL "SYSTEM" (upper case) is preferable for
>several reasons, mostly because it allows Cobol to reset the
>environment such as the terminal parameters and this doesn't specify a
>return value (at least in the documentation that I have).

Michael said the same, and that SYSTEM is not _in_ the documentation.
Do you have documentation unknown to Micro Focus insiders, or did you
just make that up?


Report this thread to moderator Post Follow-up to this message
Old Post
Robert Wagner
10-02-04 08:55 PM


Re: MF COBOL and SMTP mail
Robert Wagner <robert@wagner.net.yourmammaharvests> wrote
 
>
> Michael said the same, and that SYSTEM is not _in_ the documentation.
> Do you have documentation unknown to Micro Focus insiders, or did you
> just make that up?

From my Microfocus Manual, granted it is not Server Express 2.2:

10.8.1 Interfacing with the UNIX Operating System

The COBOL run-time system sets the terminal to a mode suitable for
COBOL. Calls to the operating system routine, system(), fail because
they do not affect the mode, as terminal settings are not modified
before or after the call.

You should replace your calls to system() with calls to "SYSTEM": this
is a subroutine provided with this COBOL system so that your operating
system can perform the same operations as system( ), but return the
terminal to shell mode before executing the command. The format of
this command is:

call "SYSTEM" using cmd-line

where the parameter is:

cmd-line 	A null-terminated command line

Upon completion of the call "SYSTEM" statement, the terminal is reset
to the mode suitable for COBOL. For example:

01  cmd-line   pic x(3)  value "sh" & x"00".
01  cmd-line2  pic x(30) value "cp f1 f2 >errfile 2>&1" & x"00".

procedure division.
display "Test" at 1101
call "SYSTEM" using cmd-line
display "Back in program" at 1201
call "SYSTEM" using cmd-line2
display "Back in program" at 1301
stop run.

As COBOL is unaware of any output from either call "system" or call
"SYSTEM", you must ensure that your screen is either not updated by a
call or is redisplayed after execution of the call.

In the example above the first command-line executed is the sh
command, which will update the screen with the system prompt and any
commands that may be entered. The second command-line copies file f1
to file f2 and redirects both the standard output and the standard
error to the file cp.log which your program can open in order to read
any output generated by running the command. The order in which you
make the redirections is significant.

Report this thread to moderator Post Follow-up to this message
Old Post
Richard
10-02-04 08:55 PM


Re: MF COBOL and SMTP mail
Robert Wagner <robert@wagner.net.yourmammaharvests> wrote
 
>
> Yes. Say call 'system' using string.
>
> If you have Oracle, look into its 'utl_smtp' library. It's faster than
> spawning a shell.

It worries me, Robert.  You claim to be a programmer and criticise
users for not telling you what they want and then you frequently
completely miss the point:

>and get back a return code in a similar way to the C system()
function?

You may be in a good position to give an actual answer and yet you
completely fail to read the question, preferring to add useless,
extraneous details about non-Cobol.

Under Solaris do you get a return code from CALL "system" ...
returning ?
Under Solaris with the same command string is it the same return as C
gives ?
Under Solaris is the return code from C's system() meaningful at all ?

Report this thread to moderator Post Follow-up to this message
Old Post
Richard
10-04-04 01:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:44 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.