Task 1 : Write a shell script that prints the message: \"Your current info is:\"
ID: 647894 • Letter: T
Question
Task 1: Write a shell script that prints the message: "Your current info is:", along with the current date, your user name, the name of your login shell, and your current directory. Add the following lines around your script and run it for 10 seconds (i.e., after 10 seconds, press Ctrl+C to stop it). Note that in order to execute the script you will have to "make it an executable".
while :
do
echo
sleep 2s
done
Task 2: Run your script again, but this time, leave it running. Start a second shell terminal (i.e., a new cygwin or terminal window), ssh to your account, find the process id of your running script, and kill it from this second terminal. Post a picture of the first terminal (where the script was running), showing the output of its last iterations and the result of killing it from another terminal.
Explanation / Answer
script.sh
echo -e "Your current information is:"
echo "Current date: $now"
echo "Your username : $(echo $USER)"
echo "Number of user login : c" ; who | wc -l
echo "The current working directory: $PWD"
2)# ps aux | less
kill -9 pid
Sorry my system is windows operating system sp I cant show output..but these script was working fine
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.