#popen()

DESCRIPTION
    open a process for reading, writing, or appending, returning TRUE if successful,
    ERR if unsuccessful
SYNOPSIS
    #popen(F,s1,s2)
ARGUMENTS
     F - a filehandle (process handle) (all caps)
    s1 - a string, or string expression, representing a command
    s2 - any among the strings:  "r", "w", "a"
EXAMPLES
outputproc(C, P)        // send all output from process (P) to communications
                        // channel (C)
                        // (C) is the comm channel (e.g., mail, syslog, print)
                        // (P) is the process (e.g., "=ll /tmp")
                        // sample use:  =outputproc(mail, "=ll /tmp")
                        if #popen(OUTPUTPROC, (P), "r")
                                while #read(OUTPUTPROC) > 0
                                        output (C) $rdlin
                                endwhile
                                do #pclose(OUTPUTPROC)
                        fi
output_other_mail(P, S, R, L)   // output conditional mail to addressee(s)
                                // beyond those specified in the alert
                                // mailcmd; we don't #pclose() the (P)
                                // proc handle at the end, instead letting
                                // pikt do it, enabling us to make this a
                                // a one-liner macro
                                // (P) is the proc handle name (e.g., MAIL)
                                // (S) is the subject (e.g., 'check this out')
                                // (R) is the recipient (e.g., osterlund\@handel)
                                // (L) is the line (e.g., $inline)

                if ! #defined(#isopen(P))
                        set #isopen(P) = #false()
                fi
                if ! #isopen(P)
                        if #popen((P), "=mailx -a 'From: piktadmin' -s (S) (R)", "w") != #err()
                                set #isopen(P) = #true()
                        else
                                output mail "\#popen() failure for: =mailx -s (S) (R)"
                                quit
                        fi
                fi
                do #write((P), (L))
SEE ALSO
    #fopen()
    #fclose()
    #pclose()
    #read()
    #write()

    Numerical Functions
    String Functions
 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2008-03-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View the list of
Related Projects
and Products