SMF in Solaris wont write to stderr/stdout ?


 
Thread Tools Search this Thread
Operating Systems Solaris SMF in Solaris wont write to stderr/stdout ?
# 1  
Old 10-18-2015
SMF in Solaris wont write to stderr/stdout ?

Hi,
I got a process (c written) that we usually run this way :
Code:
EmsChkQu >> /EMS/log/EmsChkQu.log 2>&1

When trying to use it as a service I defined it this way :

Code:
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
  <service name='site/EmsChkQu' type='service' version='0'>
    <create_default_instance enabled='true'/>
    <single_instance/>
    <dependency name='network' grouping='require_all' restart_on='error' type='service'>
      <service_fmri value='svc:/milestone/network:default'/>
    </dependency>
    <dependency name='filesystem' grouping='require_all' restart_on='error' type='service'>
      <service_fmri value='svc:/system/filesystem/local'/>
    </dependency>
    <dependency name='Active_Server' grouping='require_all' restart_on='refresh' type='path'>
      <service_fmri value='file://localhost/EMS/log/I_AM_THE_ACTIVE_CMS'/>
    </dependency>
    <method_context project=':default' resource_pool=':default' working_directory='/EMS/bin'>
      <method_credential group='root' limit_privileges=':default' privileges=':default' supp_groups=':default' user='root'/>
    </method_context>
    <exec_method name='start' type='method' exec='/EMS/bin/EmsChkQu >>/EMS/log/EmsChkQu.log 2>&1' timeout_seconds='60'>
      <method_context>
        <method_environment>
          <envvar name='LOGNAME' value='root' />
          <envvar name='SYBASE' value='/EMS/sybase'/>
          <envvar name='LIB' value='/EMS/sybase/OCS-15_0/lib:'/>
          <envvar name='PATH' value='.:/EMS/bin:/usr/ccs/bin:/usr/local/bin:/EMS/sybase/ASE-15_0/jobscheduler/bin:/EMS/sybase/ASE-15
_0/bin:/EMS/sybase/ASE-15_0/install:/EMS/sybase/SCC-3_2/bin:/EMS/sybase/DBISQL/bin:/EMS/sybase/OCS-15_0/bin:/usr/sbin:/usr/bin'/>
          <envvar name='LD_LIBRARY_PATH' value='/EMS/sybase/ASE-15_0/lib:/EMS/sybase/DataAccess64/ODBC/lib:/EMS/sybase/DataAccess64/
ODBC/dm/lib64:/EMS/sybase/OCS-15_0/lib:/EMS/sybase/OCS-15_0/lib3p64:/EMS/sybase/OCS-15_0/lib3p:'/>
          <envvar name='LD_LIBRARY_PATH_64' value='/EMS/sybase/ASE-15_0/lib:/EMS/sybase/DataAccess64/ODBC/lib:/EMS/sybase/DataAccess
64/ODBC/dm/lib64:/EMS/sybase/OCS-15_0/lib:/EMS/sybase/OCS-15_0/lib3p64:/EMS/sybase/OCS-15_0/lib3p:'/>
          <envvar name='SYBASE_ASE' value='ASE-15_0'/>
          <envvar name='SYBASE_OCS' value='OCS-15_0'/>
          <envvar name='iSYBASE_JRE7' value='/EMS/sybase/shared/JRE-7_0_7'/>
          <envvar name='SYBASE_JRE7' value='/EMS/sybase/shared/JRE-7_0_7'/>
          <envvar name='SYBASE_JRE7_32' value='/EMS/sybase/shared/JRE-7_0_7'/>
          <envvar name='SYBASE_JRE7_64' value='/EMS/sybase/shared/JRE-7_0_7'/>
          <envvar name='HOME' value='/EMS/bin'/>
          <envvar name='stderr' value='/EMS/log/EmsChkQu.log' />
          <envvar name='stdout' value='/EMS/log/EmsChkQu.log' />
        </method_environment>
      </method_context>
    </exec_method>
    <exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'>
      <method_context/>
    </exec_method>
    <property_group name='startd' type='framework'>
      <propval name='duration' type='astring' value='child'/>
      <propval name='ignore_error' type='astring' value='core,signal'/>
    </property_group>
    <property_group name='application' type='application'/>
    <stability value='Evolving'/>
    <template>
      <common_name>
        <loctext xml:lang='C'>EmsChkQu</loctext>
      </common_name>
    </template>
  </service>
</service_bundle>

Unfortunately, the svccfg return a parsing error, how can I redirect stdout/stderr to a file or my choice ?

Last edited by Don Cragun; 10-18-2015 at 07:40 AM.. Reason: Add CODE and ICODE tags.
# 2  
Old 10-18-2015
You might simply create a wrapper script that handle the redirections and define it as the smf method. e.g.:

Code:
#!/bin/ksh
exec /EMS/bin/EmsChkQu >>/EMS/log/EmsChkQu.log 2>&1

# 3  
Old 10-18-2015
Well, thats what I wanted to avoid ...
# 4  
Old 10-18-2015
Then have your C written program handling the redirection itself when called by smf.
# 5  
Old 10-22-2015
This is not an option, I'm not allowed to modify the code.
On Digital VMS system, we used to redefine the SYS$OUTPUT environment variable, why cant I do the same here ?
# 6  
Old 10-22-2015
Just use a wrapper, that's the simpler way to fix your service or explain why that would not fit your requirements.
# 7  
Old 10-22-2015
Quote:
Originally Posted by zionassedo
... ... ...
On Digital VMS system, we used to redefine the SYS$OUTPUT environment variable, why cant I do the same here ?
Because in UNIX and Linux shells, SYS$OUTPUT is not an environment variable; it is the string SYS concatenated with the contents of the environment variable OUTPUT. Most UNIX and Linux shells redirect input and output streams using redirections on the command line.

If you'd like to port a Digital VMS system shell to Solaris and, then you can use the SYS$OUTPUT environment variable to redirect output when you invoke programs from that shell.

It is just like not being able to use IBM mainframe JCL commands to run most programs on UNIX and Linux systems (the dd utility being an obvious exception).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Interactive Python 3.5+ sys.stdout.write() AND sys.stderr.write() bug?

(Apologies for any typos.) OSX 10.12.3 AND Windows 10. This is for the serious Python experts on at least 3.5.x and above... In script format sys.stdout.write() AND sys.stderr.write() seems to work correctly. Have I found a serious bug in the interactive sys.stdout.write() AND... (2 Replies)
Discussion started by: wisecracker
2 Replies

2. Shell Programming and Scripting

Have each subshell write stderr and stdout to its own logfile

Hello, As stated in the title, I do some hacked parallel processing by running multiple instances of bash scripts, each in their own subshell. The code looks like this, # launch one batch-train script in background for each value in fold group list for FOLD_GROUP in "${FOLD_GROUP_LIST}" do ... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

3. Shell Programming and Scripting

stdout, stderr redirection

Hi all, can someone help me with the next redirection? i want to redirect the stdout+stderr of a command to the same file (this i can do by prog &> file) but in addition i want to redirect only the stderr to a different file. how can i do this please? (in BASH) thanks. (4 Replies)
Discussion started by: eee
4 Replies

4. Shell Programming and Scripting

stderr/stdout

Can somebody explain to me why the diff output is not going to stderr? Yet when I issue a diff from the command line the return code is -ne 1. I am guessing diff always writes to stdout??? Is there away I can force the difff to write to stderr USING THE CURRENT template. If possible, I... (5 Replies)
Discussion started by: BeefStu
5 Replies

5. Red Hat

Make STDERR readable as STDOUT

Hi all. I am trying to use backticks in Perl to put STDERR into a string. The code is... $readkey_test = `perl -MTerm::ReadKey -e 1`; print $readkey_test; if ($readkey_test =~ m/]/) { print "ReadKey not installed...\n"; } else { print "ReadKey installed...\n"; } If it comes up... (3 Replies)
Discussion started by: austinharris43
3 Replies

6. Shell Programming and Scripting

sending stdout and stderr to a file

working on a c sell script I think I understand the concept of it, which is: filename >> file.txt (to appaend) or filename | tee -a file.txt (to append) The problem is that my shell script is used with several parameters, and these commands don't seem to work with just filename. They... (2 Replies)
Discussion started by: mistermojo
2 Replies

7. Shell Programming and Scripting

How to use tee with stdout and stderr?

I have been doing this: make xyz &> xyz.log &; tail -f xyz.log The problem with this is that you never can ge sure when "make xyz" is done. How can I pipe both stderr and stdout into tee so both stderr and stdout are copied both to the display and to the log file? Thanks, Siegfried (3 Replies)
Discussion started by: siegfried
3 Replies

8. Solaris

Solaris has a lot of bugs, fstream wont write to file correctly!

I've got a c++ program that works fine on Linux, compiles on Solaris fine with g++, but will not write to a fstream correctly in a class object. And I've run into numerous other bugs in the disk management. Jon (4 Replies)
Discussion started by: Joncamp
4 Replies

9. Shell Programming and Scripting

precedence of stderr and stdout

#!/usr/bin/perl open(STDOUT, ">>$Textfile") open(STDERR, ">>$Textfile") print "program running\n"; $final = join("+", $initial,$final) #5 close (STDOUT); close (STDERR);Hi all, above is my perl code. Notice i have captured the stdout and stderr to the same textfile. my code is expected to... (1 Reply)
Discussion started by: new2ss
1 Replies

10. Shell Programming and Scripting

Redirect stdout and stderr

How can I redirect and append stdout and stderr to a file when using cron? Here is my crontab file: */5 * * * * /dir/php /dir/process_fns.php >>& /dir/dump.txt Cron gives me an 'unexpected character found in line' when trying to add my crontab file. Regards, Zach Curtis POPULUS (8 Replies)
Discussion started by: zcurtis
8 Replies
Login or Register to Ask a Question