Piping output to a C-shell script from another command - HOW?

Piping output to a C-shell script from another command - HOW?

Post by Alice Ho » Wed, 28 Sep 1994 01:30:39



I have written a printing program in C-shell script which accepts command-
line arguments. The usage is as follows:

print [-p printer] [-f format] [-s papersize] [-o orientation] file...

I want to adapt it so that if the user can do the following sort of
thing

ls | print -p laser -f text

ie. so that the output from ls comes out on the printer.

At the moment, you have to enter a filename to print.

Can anyone please tell me how to do this sort of thing in C-shell
programming?(The program works perfectly as it now stands, but
I would like to be able to pipe output from Unix commands such as
ls to it).

Any suggestions would be greatly appreciated!

Thanks in advance.

Tim Porter.
Forestry Authority Research (Forestry Commission).

PS. I am using SunOS 4.1.2 on Suns.

 
 
 

Piping output to a C-shell script from another command - HOW?

Post by Jerzy Tarasi » Sun, 02 Oct 1994 20:23:03


A> I have written a printing program in C-shell script which accepts command-
A> line arguments. The usage is as follows:
A> print [-p printer] [-f format] [-s papersize] [-o orientation] file...
A> I want to adapt it so that if the user can do the following sort of
A> thing
A> ls | print -p laser -f text
A> ie. so that the output from ls comes out on the printer.
A> At the moment, you have to enter a filename to print.

I don't know WHAT asks for the filename. Perhaps assuming default
filename "-" can help (i.e. if you detect no filename parameter,
pass "-" as filename to the program which prints).
But: lp, lpr and pr can print standard input without using "-",
although lp allows it to specify named files + standard input.

 
 
 

1. Shell Script Help (C-Shell Script)

In my class we had to write a C program and now we have to write a shell
script to do the exact same thing. I am not sure where to get started using
tr and sed to accomplish this assignment. Here is the assignmnet...

--------------------------------------------------------------
(1) remove all non-printing characters (character codes 1 through 31,
   and 127) and replace them with the same sort of codes the vi
   editor uses.  For example, the bell character (character code 7)
   is replaced by the two printable characters "^" and "G" (G is the seventh
   letter of the alphabet).  Appendix I of Foster lists the ASCII character
   set, and it shows all the proper two-character sequences that should
   be used for the non-printing characters.  There are two special cases:
   Replace the delete character by "^?".  Newlines should be replaced by a
   dollar sign ("$") and then an actual newline.
   **you may ignore NUL (character code 0)**

(2) delete all non-ASCII characters (those with character codes 128 through
255).

(3) truncate all output lines that would otherwise extend past column 72.
Begin
   reading the data on the next line after ignoring the rest of the
character past column 72.

Make sure it reads from stdin and prints to stdout.  It should be comprised
of standard UNIX utilities (that is, it should not invoke any specialized C
programs
that you may consider writing). You MUST make use of pipes rather than using
files to store intermediate results.  Don't make this assignment
unnecessarily hard: the whole program can be done in ONE line (not counting
all the documentation lines).
--------------------------------------------------------------

I was thinking that (1) could be accomplished by using a tr line like ( tr
'\001-\011' '\136') but that replaces some of the non printing with the ^,
how would i get the letter in there and would I have to have a bunch of
those tr commands piped together just to accomplish (1)?

Some help on this would really really be appreciated as its due on Monday
and I've hit a brick wall on this one.

-mogrefy

2. Dell Precison 650

3. pipe output from c program to a korn shell script

4. migratepv

5. pipe c output to shell script

6. persistent connection to other server via apache

7. c-shell script won't run from korn-shell / SETUID

8. Problem mounting floppy drive

9. a question about executing a shell script (c-shell)

10. exit status of the command in pipe from shell & named pipe

11. c-shell: use of << EOF and piping

12. output of command as variable in shell script

13. Directing Shell Script output to a file from command line