A Shell Script To Locate Executable Files Project Requirement Help Write a shell script to locate executable files. This script takes a list of file names
A Shell Script To Locate Executable Files Project Requirement Help Write a shell script to locate executable files. This script takes a list of file names from the command line and determines which would be executed had these names been given as commands. Please refer the Syllabus for the Assignment / Project Requirements and Guidelines The search path should be based only on the user’s PATH environment variable. You shall not use the Unix which command, the ksh whence (type) command, the locate command, or the bash type command. The code for the script shall not use the UNIX ls command to determine if the file is executable or if it exists. The script should find only the first occurrence of the “file”. If the file is not found, the script the following
and determines which would be executed had these names been given as commands.
Please refer the Syllabus for the Assignment / Project Requirements and Guidelines
The search path should be based only on the user’s PATH environment variable. You shall not use the
Unix which command, the ksh whence (type) command, the locate command, or the bash type
command.
The code for the script shall not use the UNIX ls command to determine if the file is executable or if it
exists.
The script should find only the first occurrence of the “file”. If the file is not found, the script the
following
NOT FOUND
would be replaced by the name of the “file” you didn’t find.
If the first parameter is ‘-a’, then the script should print all occurrences of the executable file in the
user’s
path. Again, if the file was not on the path, an error message should be displayed.
The find command shall not be used.
A project using temporary files will not be graded.
NOTE: The shell variable PATH defines the search path for the directory containing the command.
Alternative directory names are separated by a colon (:). The current directory can be specified by two
or
more adjacent colons, or by a colon at the beginning or end of the path list.
If the command name contains a / then the search path is not used, you just check if the command/file
specified is executable and not a directory. Otherwise, each directory in the path is searched for an
executable file.
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh -a tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./tar
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./tar not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh /bin/tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh tar ls sleep
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
/bin/ls
/bin/sleep
PROGRAM OUTPUT
==> /bin/tar
/bin/ls
/bin/sleep
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh mar1.sh
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> mar1.sh not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./mar1.sh
RESULT ==> PASSED
EXPECTED RESULT ==> ./mar1.sh
PROGRAM OUTPUT
==> ./mar1.sh
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh skekek
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> skekek not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./skekek
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./skekek not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./class
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND (this is a directory)
PROGRAM OUTPUT
==> ./class not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh no-read
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> no-read not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./no-execute
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./no-execute not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh no-execute
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> no-execute not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh any-old-file
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> any-old-file not FOUND
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh -a tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./tar
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./tar not FOUND
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh /bin/tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh tar ls sleep
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
/bin/ls
/bin/sleep
PROGRAM OUTPUT
==> /bin/tar
/bin/ls
/bin/sleep
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh mar1.sh
RESULT ==> PASSED
EXPECTED RESULT ==> ./mar1.sh
PROGRAM OUTPUT
==> ./mar1.sh
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./mar1.sh
RESULT ==> PASSED
EXPECTED RESULT ==> ./mar1.sh
PROGRAM OUTPUT
==> ./mar1.sh
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh skekek
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> skekek not FOUND
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./skekek
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./skekek not FOUND
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./class
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND (this is a directory)
PROGRAM OUTPUT
==> ./class not FOUND
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh no-read
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> no-read not FOUND
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./no-execute
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./no-execute not FOUND
PATH
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh no-execute
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
PATH
==> no-execute not FOUND
==> :/bin:/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh any-old-file
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> any-old-file not FOUND
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh -a tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./tar
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./tar not FOUND
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh /bin/tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh tar ls sleep
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
/bin/ls
/bin/sleep
PROGRAM OUTPUT
==> /bin/tar
/bin/ls
/bin/sleep
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh mar1.sh
RESULT ==> PASSED
EXPECTED RESULT ==> ./mar1.sh
PROGRAM OUTPUT
==> ./mar1.sh
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./mar1.sh
RESULT ==> PASSED
EXPECTED RESULT ==> ./mar1.sh
PROGRAM OUTPUT
==> ./mar1.sh
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh skekek
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> skekek not FOUND
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./skekek
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./skekek not FOUND
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./class
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND (this is a directory)
PROGRAM OUTPUT
==> ./class not FOUND
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh no-read
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> no-read not FOUND
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh ./no-execute
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./no-execute not FOUND
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh no-execute
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> no-execute not FOUND
PATH
==> /bin::/usr/local/bin:/usr/bin/X11
RAN
==> mar1.sh any-old-file
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> any-old-file not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh -a tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh ./tar
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./tar not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh /bin/tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh tar ls sleep
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
/bin/ls
/bin/sleep
PROGRAM OUTPUT
==> /bin/tar
/bin/ls
/bin/sleep
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh mar1.sh
RESULT ==> PASSED
EXPECTED RESULT ==> ./mar1.sh
PROGRAM OUTPUT
==> ./mar1.sh
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh ./mar1.sh
RESULT ==> PASSED
EXPECTED RESULT ==> ./mar1.sh
PROGRAM OUTPUT
==> ./mar1.sh
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh skekek
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> skekek not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh ./skekek
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./skekek not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh ./class
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND (this is a directory)
PROGRAM OUTPUT
==> ./class not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh no-read
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> no-read not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh ./no-execute
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./no-execute not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh no-execute
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> no-execute not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:
RAN
==> mar1.sh any-old-file
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> any-old-file not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh -a tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh ./tar
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./tar not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
PATH
==> /bin/tar
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh /bin/tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh tar ls sleep
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
/bin/ls
/bin/sleep
PROGRAM OUTPUT
==> /bin/tar
/bin/ls
/bin/sleep
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh mar1.sh
RESULT ==> PASSED
EXPECTED RESULT ==> ./mar1.sh
PROGRAM OUTPUT
==> ./mar1.sh
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh ./mar1.sh
RESULT ==> PASSED
EXPECTED RESULT ==> ./mar1.sh
PROGRAM OUTPUT
PATH
==> ./mar1.sh
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh skekek
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> skekek not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh ./skekek
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./skekek not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh ./class
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND (this is a directory)
PROGRAM OUTPUT
==> ./class not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh no-read
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> no-read not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh ./no-execute
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> ./no-execute not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh no-execute
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> no-execute not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh any-old-file
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> any-old-file not FOUND
PATH
==>
/opt/SUNWspro/bin:/bin:/usr/dt/bin:/usr/openwin/bin:/usr/local/bin:/opt/sfw/b
in:/usr/sfw/bin:.:/usr/ccs/bin:/usr/ucb:/usr/platform/SUNW,Sun-FireV240/sbin:/sbin:/usr/sbin:/usr/local/sbin:/usr/sadm/bin:/usr/lib:/usr/platfor
m/sun4u/sbin
RAN
==> mar1.sh ls
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/ls
PROGRAM OUTPUT
==> /bin/ls
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh x1banner
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> x1banner not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh tcc2
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> tcc2 not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh tcc3
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> tcc3 not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh mar1.sh1
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND
PROGRAM OUTPUT
==> mar1.sh1 not FOUND
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:/users/faculty/mrichard/example:.
RAN
==> mar1.sh “do it”
RESULT ==> PASSED
EXPECTED RESULT ==> /users/faculty/mrichard/example/do it
PROGRAM OUTPUT
==> /users/faculty/mrichard/example/do it
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:.
RAN
==> mar1.sh “/users/faculty/mrichard/example/do it”
RESULT ==> PASSED
EXPECTED RESULT ==> /users/faculty/mrichard/example/do it
PROGRAM OUTPUT
PATH
==> /users/faculty/mrichard/example/do it
==> /bin:/usr/local/bin:/usr/bin/X11:/users/faculty/mrichard/example:.
RAN
==> mar1.sh “do it” ls
RESULT ==> PASSED
EXPECTED RESULT ==> /users/faculty/mrichard/example/do it
/bin/ls
PROGRAM OUTPUT
==> /users/faculty/mrichard/example/do it
/bin/ls
PATH
==> /bin:/usr/local/bin:/usr/bin/X11:/users/faculty/mrichard/example:.
RAN
==> mar1.sh class
RESULT ==> PASSED
EXPECTED RESULT ==> NOT FOUND file is a directory
PROGRAM OUTPUT
==> class not FOUND
PATH
==>
/opt/SUNWspro/bin:/bin:/usr/dt/bin:/usr/openwin/bin:/usr/local/bin:/opt/sfw/b
in:/usr/sfw/bin:.:/usr/ccs/bin:/usr/ucb:/usr/platform/SUNW,Sun-FireV240/sbin:/sbin:/usr/sbin:/usr/local/sbin:/usr/sadm/bin:/usr/lib:/usr/platfor
m/sun4u/sbin
RAN
==> mar1.sh -a tar
RESULT ==> PASSED
EXPECTED RESULT ==> /bin/tar
PROGRAM OUTPUT
==> /bin/tar
PASSED ==> 80
100%
FAILED ==> 0
0%
Purchase answer to see full
attachment
We've got everything to become your favourite writing service
Money back guarantee
Your money is safe. Even if we fail to satisfy your expectations, you can always request a refund and get your money back.
Confidentiality
We don’t share your private information with anyone. What happens on our website stays on our website.
Our service is legit
We provide you with a sample paper on the topic you need, and this kind of academic assistance is perfectly legitimate.
Get a plagiarism-free paper
We check every paper with our plagiarism-detection software, so you get a unique paper written for your particular purposes.
We can help with urgent tasks
Need a paper tomorrow? We can write it even while you’re sleeping. Place an order now and get your paper in 8 hours.
Pay a fair price
Our prices depend on urgency. If you want a cheap essay, place your order in advance. Our prices start from $11 per page.