For this exercise we will create a startup script. This script will start the VI
ID: 3919011 • Letter: F
Question
For this exercise we will create a startup script. This script will start the VI editor. You can use any kind of patterns, but its always recommended to use case statement, when you’re testing on values of primitives. (ie. integers or characters).
You will call your script startapp and it will take one parameter.
The parameters should be start, stop and restart.
start: You must start VI as a background process so you can still have a shell
stop: You will need to use the kill command to kill the VI process
restart: First your script with kill the vi process, after that it will start a new instance of vi
Some use case examples:
1) Starting VI
[barreto@linuxbox ~]./startapp start
[barreto@linuxbox ~]Starting VI
2) Stoping VI
[barreto@linuxbox ~]./startapp stop
[barreto@linuxbox ~] VI stopped
3) Restarting VI
[barreto@linuxbox ~]./startapp restart
[barreto@linuxbox ~] Stopping VI ...
[barreto@linuxbox ~] Starting VI
Explanation / Answer
SOLUTION:
According to the given data the following code is given:
//the startapp script accepts three parameters
// @start run the process in background
$i=='start'
fg& vi
//@stop kill the process, $! gets the job id of backgorund process
$i=='stop'
kill KILL $!
// @restart first kill the job id then start the instance
$i=='restart'
kill $!
fg& vi
therefore by considering the above parameters we can get required output
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.