This is my question, below the question is the template
Write and execute a Bourne shell script called homework that will
From within the script, create three background processes:
a) (2 points) one that saves a long listing of your hidden files to a file named hiddenlist
b) (2 points) one that saves a full listing of the status of your current running processes to a file named pstat
c) (2 points) one that stores only the count of the number of words from the file homework2 into a file named wordcount
d) (1 point) issue a command to wait for ALL three background processes to complete.
e) (1 point) give the user a message stating that the process are completed
1.There are no variables.
2. Relevant commands, code, script, alogrithems.
The relevant command would be cat to create files the | to join commands
for a I would need ls -la
for b I would need ps
for c I would need wc
for d I would need wait
for e I would need echo
3. Here is one of the many attempts I have made to solve this problem, I have many more but don't want
to flood the forum with my failed attempts.
4. California State University Fullerton, Fullerton California USA Floyd Holiday CPSC253U
Last edited by Don Cragun; 03-22-2015 at 03:04 AM..
Reason: Add CODE and ICODE tags.
Please use CODE tags when displaying sample input, output, and code.
You should look at the man page for your shell (presumably man sh for the Bourne shell). Look for the words "Background" and "background" in that man page for ways to run a process in the background and restrictions on what a background job can do. You don't seem to have anything in your script to run any processes in the background.
Also look for "Redirection" and "redirection" to see what > file does when it is used as a complete command, and what it does when it is used as part of a larger command.
And look for "Pipeline" and "pipeline". Having two processes in a pipeline that redirect standard output to the same file creates a race condition that may make it impossible to determine which process writing to that file will actually store lasting data in that file.
Then take a look at the man page for the cat utility. The command:
doesn't necessarily create an empty file named file; it depends entirely on what cat reads from its standard input.
Is your understanding of part "a)" of your assignment that the output should include all of your files (including hidden files); or that the output should only include your hidden files?
Thank you for pointing me in the right direction. As it turns out the commands on the power point I was using were not compatible with my shell. I'm honestly not sure why, but I'm happy I got it going.
Thank you for pointing me in the right direction. As it turns out the commands on the power point I was using were not compatible with my shell. I'm honestly not sure why, but I'm happy I got it going.
Shells read commands written in the shell programming language. The shell programming language has very special meanings for the single quote, double quote, and backquote characters. Power-point and other text formatting tools use things like opening and closing single quotes and opening and closing double quotes that are fine for humans reading text, but are not valid in the shell programming language.
Note also that the shell (and most other UNIX and Linux utilities) expect lines to be terminated by a <newline> character while Windows systems have utilities that expect lines to be terminated by a <carriage-return><newline> character pair. When preparing text to be processed on UNIX and Linux systems, be sure that whatever editor you choose uses <newline> as its line terminator.
I think the 'cat to create files' is misleading and nonsense in general. The > creats the file - no need for cat. And here is no need for a | either.
You run 3 simple commands in the background(!), and wait for them.
I am suppose to make a program that cuts the extension off of a file. It uses that .ext to decide which program needs to be used to open the file. This only finds the name of the program from a list of programs I made. My problem is when it has the name of the program it needs to use, how can I... (3 Replies)
Attempting to write a script to eventually notify me via email for when there is packetloss across the backbone. I am looking for values greater than 0% in the mtr field.
#!/bin/sh
target=www.google.com
date +"%D"_"%T" >> /home/rich/mtr.log
echo "----------------------------------------" >>... (1 Reply)
I have 2 separate Bourne shell scripts with 2 questions in Sun O/S & UNIX environment.
Question 1: One of the scripts is supposed to be executed by "root" user only but cannot be executed after user executes "su - oracle". How can I check in the script whether the current user is "root" user?... (8 Replies)
He guys.
Basically I want to make a script that can add, delete and view stuff in a external file called config.txt. I can open it up in Joe but im not sure how to read in the user input or using commands automatically in joe to edit, save then quit.
Problem area below:
1) echo "Add... (1 Reply)
Bourne: How to invoke an alias from within a shell script
If I type in the alias in the command line, it runs
If I insert that same alias into my shell script and run the shell script, the alias is not invoked.
Help please. (2 Replies)
Dear Bourne Shell Expert,
I am trying to change the current working directory from within a Bourne Shell script. Simply enough i thought !
As I am sure you are well aware, Inside the script i echo `pwd` and it seems ok, but the shell spawns another shell to execute this and as such, when my... (10 Replies)
Hi,
I'm a newbie to UNIX scripting and I'm having some trouble compiling my script. I'm using the Bourne Shell and cannot seem to use the substr function correctly. I'm trying to extract the last two digits of a year that's stored in a variable based off of a condition. I've searched the... (4 Replies)
Hello,
I'm throwing this out there as a novice to the Unix world...I've
been working on a project that requires me to ouput (using the echo command) a list of names in a single column format, but the problem is the input is in row format followed by a blank space...If anyone could give me a... (2 Replies)
Hi all,
Can somebody answer the following query
Thanks,
Srinivas
A shell program that takes one or any number of file directory names as input; sorts the directories given as parameters jointly in the ascending or decending order of choice For EX : dips abc etc desc will sort the files... (2 Replies)
i have this assignment.. and i mad this script but there is something wrong with it.. if anyone can tell me.. watz going on... i would appreciate it.. tHnX in advance..
count=1
val=$2
op=$1
ans=0
if
then
if
then
while
do
... (7 Replies)