1. The problem statement, all variables and given/known data:
I'm running into a problem with my program concerning the actual output it does. When I open the file that gets the output, it contains
a large number of hex(?) variables and not what the user wants. The problem should be with the read statement, as it seems the write statement works fine.
The user is supposed to enter something like:
via the command line
I don't understand how exactly I would get the input from the file being piped (in this example: cat date). I assumed just having the
read statement would automatically take in whatever is passed to it, but I guess that's not correct.
I have contacted the professor but his answers did not help at all.
P.S., we HAVE to use read and write for this particular assignment, so any alternative functions would not be acceptable on submission.
2. Relevant commands, code, scripts, algorithms:
Write a program similar to the Unix "tee" command.
Due Wednesday April 10 at class time.
The assignment is worth 100 points.
Program
The Unix "tee" command is used to pull out copies of a data stream. It is typically used in conjunction with pipes
(analogous to a T-joint in plumbing, hence the name). It takes all data from the standard input and copies it to the
standard output, but also copies it into files named as its arguments. For example, the command
would take the data coming from the cat side of the pipe and store it in the files a, b, and c, in addition to sending it on to the wc side of the pipe.
The -a option to the "tee" command changes the functionality: instead of overwriting the output files, the data stream is appended to the output files. Your program should also implement this functionality.
Your program should be called "z123456.tee" where z123456 should be replaced with your z-ID. Input
A sample input file can be found [can't link] Error Checking
If any output file cannot be opened, then that file should be skipped. Remaining files should be processed. Output
% z123456.tee Usage: z123456.tee [-a] out_file1 [ out_file2 ...] Sends lines of the standard input to all of the output files
and to the standard output. The -a option will append the output to all files instead of overwriting them. Other Points
make sure that your assignment is contained in a single file called "z123456.cxx" based on your Z-id
make sure that your program compiles, links and runs fine on your Linux system, turing or hopper.
Submission
Submit your C++ source code file via Blackboard below.
3. The attempts at a solution (include all code and scripts):
Here's what I have so far: 4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Northern Illinois University, Dekalb (IL), United States, Ege, UNIX 330
Thanks, guys!
Last edited by vbe; 04-11-2013 at 06:31 AM..
Reason: more formatting + typo
I'm on Ubuntu 14.04 and I manually updated my coreutils so that "tee" is now on version 8.27
I was running a script using bash where there is some write to pipe error at some point causing the tee command to exit abruptly while the script continues to run. The newer version of tee seems to prevent... (2 Replies)
Hi,
How to append content into a file using tee command
echo " file1 is archived"| tee -a archive.txt
echo " file2 is archived"| tee -a archive.txt
echo " file3 is archived"| tee -a archive.txt
how to append content as new rows in the archive.txt
Thanks,
Srinadh. (4 Replies)
I have code fragment like
{
aa
bb
cc
} > $LOG
aa bb cc, all call function "ff", I want "ff" to print on the screen,but others do not print on the scree, is there a method? I can't use "tee", becasue tee I meet the write "error"
ff()
{
echo "hello"
} (2 Replies)
BACK STORY:
I have a script build.py . (It's for creating the ISO file for a special edition of Swift Linux.) This build.py script executes the mintConstructor.py script that I use to modify the Regular Swift Linux ISO to get the special edition Swift Linux ISO. The lines of the script that... (2 Replies)
First post here, so hopefully all guidelines are followed, and thanks in advance for any replies.
I'm working on a shell script(BASH) that processes a csv file and performs various tasks with the data. All is well, except I want to use 'tee' to send output from 'wc' to a file as well as pipe it... (4 Replies)