UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old August 3rd, 2004, 01:57 PM
pinemind pinemind is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 15 pinemind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 23 m
Reputation Power: 0
Shell Script - Output background process command to file problem

Hi everyone,

Just started shell scripting for some simple tasks in Solaris 8. Here's my problem. I'm running a shell script from the crontab file to start and stop some services. There is a list of commands like the following
Code:
#!/bin/csh

$DIR/runthis stop >> logfile
date >> logfile

$DIR/runthis2 stop >>logfile
date >> logfile

$DIR/runthis start & 
date >> logfile

$DIR/runthis2 start &
date >> logfile


Outputting the stop commands and date info to the logfile works fine. The problem is, I need to output the stdout of the commands issued in the background (&). If I put the append command (>>) after the ampersand (space or no space) with the logfile name, I get an "Invalid null char" error.

I have searched the web to try and find out how you can append the output of a background process command to a file and there is nothing about it. I know the command outputs to the console because if I run it by itself, I get the output desired.

Is there anyway to capture the output of a background process?

Peace,

Justin

Reply With Quote
  #2  
Old August 3rd, 2004, 06:41 PM
Perderabo Perderabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 121 Perderabo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 54 sec
Reputation Power: 5
I don't use csh very much, but try:
runthis start >> logfile &

Reply With Quote
  #3  
Old August 3rd, 2004, 11:11 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,059 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 3 h 46 m 33 sec
Reputation Power: 8
Justin

csh on command line is an exceleent tool.
csh in scripts is buggy, don't use it at all.
what you want is:
Code:
#!/bin/sh
   (
   do-this
   do-that
   do-more &
   ) >logfile

or '>>logfile' for append
remember cron has a very restricted environment, so
$DIR maybe NOT set.

Reply With Quote
  #4  
Old August 4th, 2004, 08:38 AM
pinemind pinemind is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 15 pinemind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 23 m
Reputation Power: 0
guggach,

By aggregating the commands together, will the logfile still contain the output from each separate command or just the last one in the list?

Justin

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Shell Script - Output background process command to file problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway