** Attempt to write with no current output destination. (165)

deepan_sainik

New Member
Hi All,

I deleveloped a program to send emails when I select mail in "output to" of all reports. To be more clear, i have defined a printer "mail" and given the path of the script file which calls the program written to send the email.

The script looks as below.

/******************************************/

OUTFILE=$HOME/outfile.txt;export OUTFILE
cat $* > $OUTFILE
/bin/tools/unix2dos $OUTFILE
/*unix2dos is a script to convert unix format to dos format*/

##----------------------------------------------##
## Run PROGRESS program to find email address ##
## and send attachment as an email to Notes ##
##----------------------------------------------##

display_banner=no;export display_banner
mpro -b -p xxmailx.p -pf $HOMEBIN/db_pf.pf -d dmy
/******************************************/

When i execute the above script i am getting the error "** Attempt to write with no current output destination. (165)".

I even tried to run just the command "mpro -b -p xxmailx.p -pf $HOMEBIN/db_pf.pf -d dmy" (last line of the script file) in prompt but still it is giving the same error.

FYI, the xxmailx.o program works very well from progress editor.

Kindly help.

Thanks and Regards,
Deepan N.
 

deepan_sainik

New Member
Hi Ramamurthy and All,

I am still getting the same error. Please help.

content of script used:

OUTFILE=$HOME/outfile.txt;export OUTFILE
cat $* > $OUTFILE
/usr/users/ssdb_mgr/unix2dos $OUTFILE
##----------------------------------------------##
## Run PROGRESS program to find email address ##
## and send attachment as an email to Notes ##
##----------------------------------------------##
display_banner=no;export display_banner
mbpro -b -p xxmailx.p -pf $SSDBPF/ssdb_user.pf -d dmy

xxmailx.p program content:

/*-----------------------------------------*/
/* Variables used by Email with attachment */
/*-----------------------------------------*/
define variable wk_userid as character format "X(8)" no-undo.
define variable wk_home_dir as character format "X(50)" no-undo.
define variable wk_scriptname as character format "X(50)" no-undo.
define variable wk_outfilename as character format "X(80)" no-undo.
define variable wk_subject as character format "X(80)" no-undo.
define variable wk_site as character init "UNKNOWN" no-undo.
define variable wk_attachment as character format "X(80)" no-undo.
define variable wk_messagebody as character format "X(80)" no-undo.
define variable wk_filesize as integer no-undo.
define variable wk_maxfilesize as integer no-undo.
define variable wk_limitfilesize as logical init "NO" no-undo.
define variable wk_allow_attach as logical init "YES" no-undo.
define variable wk_defaultmax as integer init "102400" no-undo.
define variable wk_user_mail as character no-undo.
/*---------------------*/
/* Main Program Begins */
/*---------------------*/
/**------------------**/
/** Initialisation **/
/**------------------**/
assign
wk_maxfilesize = 0
wk_limitfilesize = NO
wk_allow_attach = YES
wk_home_dir = OS-GETENV("HOME")
wk_scriptname = wk_home_dir + "/temp_script_for_email"
wk_attachment = "Undefined"
wk_messagebody = wk_home_dir + "/message.txt"
wk_userid = userid(sdbname("ssdb"))
wk_user_mail = "".
find first QG_User where user_id = wk_userid
no-lock no-error.
if available QG_User then
do:
wk_user_mail = trim(user_mail).
end. /*if available QG_User*/

assign
wk_site = wk_userid + "_SSDB"
wk_outfilename = OS-GETENV("OUTFILE").
if wk_outfilename matches "*.pdf" then
do:
wk_attachment = wk_site + ".PDF".
wk_subject = "See file attached in pdf format requested from "
+ "SSDB on " + (string(today)) + " at " + (string(time,"HH:MM:SS")).
end. /*if wk_outfilename matches "*.pdf"*/
else
do:
wk_attachment = wk_site + ".TXT".
wk_subject = "See file attached in txt format requested from "
+ "SSDB on " + (string(today)) + " at " + (string(time,"HH:MM:SS")).
end. /*else*/
/**---------------------------------------------------------------**/
/** Construct the mailx script if wk_user_mail is not blank **/
/**---------------------------------------------------------------**/
if wk_user_mail <> "" then
do:
/**---------------------------------------------------------**/
/** Check whether attachment filesize limit is configured **/
/** or not. If so, retrieve the filesize set and use it. **/
/**---------------------------------------------------------**/
assign wk_maxfilesize = 10000000 no-error.
if error-status:error then
do:
wk_maxfilesize = wk_defaultmax.
wk_limitfilesize = YES.
end.
else /*if no error*/
do:
wk_limitfilesize = YES.
end.
wk_limitfilesize = NO.
/**-------------------------------------------------------**/
/** If wk_limitfilesize is TRUE, check the attachment **/
/** byte size to make sure it does not exceed the value **/
/** set in wk_maxfilesize **/
/**-------------------------------------------------------**/
input from value(wk_outfilename).
seek input to end.
assign wk_filesize = seek(input).
if (wk_limitfilesize = YES) and
(wk_filesize > wk_maxfilesize) then
wk_allow_attach = NO.
else
wk_allow_attach = YES.
/**---------------------------**/
/** Create the mailx script **/
/**---------------------------**/

if wk_allow_attach = YES then
do:
output to value(wk_scriptname).
put unformatted
'uuencode ' wk_outfilename ' ' wk_attachment ' | '
'mailx -s '
'"' wk_subject '" '
wk_user_mail.
output close.
end. /*if wk_allow_attach = YES*/
else /*if wk_allow_attach = NO*/
do:
wk_subject = "Attachment file too big and prevented from reaching you".
output to value(wk_messagebody).
put unformatted
'The attachment file you have requested from ' +
'SSDB on ' +
(string(today)) + " at " +
(string(time,"HH:MM:SS"))
skip
'had exceeded the maximum file size allowed.'
skip(2)
'Attachment file size : ' +
left-trim(string(wk_filesize,">>>,>>>,>>>,>>9")) +
' bytes'
skip(1)
'Maximum size allowed : ' +
left-trim(string(wk_maxfilesize,">>>,>>>,>>>,>>9")) +
' bytes'
skip(2)
'This is an automated message from ' + 'SSDB.'
skip(1)
'Please do not reply to sender.'
skip(1).
output close.
output to value(wk_scriptname).
put unformatted
'mailx -s '
'"' wk_subject '" '
wk_user_mail
' < ' wk_messagebody.
output close.
end. /*else*/
/**------------------**/
/** Run the script **/
/**------------------**/
unix silent chmod a=rwx value(wk_scriptname). /*Make script exectuable*/
unix silent value(wk_scriptname). /*Execution*/
unix silent rm -f value(wk_scriptname). /*Clean up*/
unix silent rm -f value(wk_messagebody). /*Clean up*/
end. /*if wk_user_mail <> ""*/
/*----------------*/
/* End of Program */
/*----------------*/


Thanks and Regards,
Deepan N.
 

subhendra

New Member
Hi,

Although I use different command to convert from UNIX to DOS format, looks like output device is not specified.

e.g.

/bin/tools/unix2dos $OUTFILE > file1

Please try this out and let me know if this work.

Subhendra.
 
Top