delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/16/23:49:59

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <20040417034945.7220.qmail@web12403.mail.yahoo.com>
Date: Fri, 16 Apr 2004 20:49:45 -0700 (PDT)
From: Christopher Spears <cspears2002 AT yahoo DOT com>
Subject: ppd
To: cygwin AT cygwin DOT com
MIME-Version: 1.0

Okay, some people have mentioned that I should explain
what I am trying to do with my csh script.  I think
this is true.  Basically, the script is called
ppd.txt, and I wrote it in Notepad.  ppd stands for
prepend.  The script will take a filename as its
argument and read from standard input.  Basically, it
takes input from something like:

2% (date; du ~) | ./ppd.txt ~/disk_storage&

The script takes the results of date and du and
appends them to the beginning of a file called
disk_storage.  Here is the script:

#!/bin/tcsh -x

#csh script to prepend standard input to file argument
#Version 1

#name temp file
set tf = /tmp/ppd.$$

#get argument name
set dest = "$argv[1]"

#copy standard input, $dest to $tf
cat - "$dest" > "$tf"

#replace original file
mv "$tf" "$dest"

With help from a lot of members of this digest (thank
you!), I have debugged it to the point where I do not
get any error messages.  However when I run the
command I mentioned earlier:

2% (date; du ~) | ./ppd.txt ~/disk_storage&

Nothing is prepended to disk_storage!  I created
disk_storage before running this script because I was
getting an error message when the script could not
find a file with that name.  Can anyone tell me what I
have done wrong?  Any suggestions on writing scripts
in cygwin would be appreciated, too!

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019