Please help me with this question! Write a command file (a .bat file on Windows,
ID: 3648727 • Letter: P
Question
Please help me with this question!Write a command file (a .bat file on Windows, an .sh file on OSX/*nix) containing the following command:
navigate to the folder C:Temp (you may assume it exists, you should create it on your own computer if it doesn't). Note: Linux and Mac users should pick some other temporary folder, such as /tmp.
create a file within that folder called "Example.txt". This file may be empty, or it may contain some text.
create another file, which name should not be hardcoded, but should be accepted as an argument to the batch file
make the file read only
list all the files in this folder
create a subfolder called "Smuuu" and navigate into it
execute the command "whoami" and route the output to the file results.txt
execute the command "ping" to check if www.ru.is is running, and route the output to the results.txt file, but make sure it doesn't overwrite the content from the previous command
use the command "grep" (note: requires Cygwin on Windows) to check if the file results.txt contains the words "timed out"
Note: during development, you should use a file with the file extension .bat (on Windows) or .sh (on Linux), but when you hand in your result you should change it to .txt.
Also, make sure you add a comment, stating what type of OS you are using.
Explanation / Answer
# TO run this, enter sh cram.sh to run # Developed with Mac OSX 10.8 echo "Your file name is $1" cd /tmp touch Example.txt touch $1 chmod 444 $1 mkdir Smuu cd Smuu whoami > results.txt ping -c2 www.ru.is >> results.txt cat results.txt | grep timeout
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.