Please type out and post No pictures, please. Write a Perl script to calculate t
ID: 3749132 • Letter: P
Question
Please type out and post No pictures, please. Write a Perl script to calculate the following.
Write a script to create the following directory structure in a directory of user's choice. The user can supply this input as an argument; if not, prompt the user to enter one from the command line. 8. (User selected existing directory) Data Image Cache Edit the script in the prior question. Check if the user input (an existing directory) is valid; if not, ask the user to enter it again. If the "Data" directory exists, then prompt for user actions: cancel or overwrite. - this might be more difficult than using Bash. You can skip this one and come back later. 9.Explanation / Answer
Solution 8:
directory1=$1 #the directory name given as the arguments
cd directory1 #moving to directory1
mkdir Data #making directory Data
cd Data #moving to directory Data
mkdir Image #making directory image
mkdir Cache #making directory Cache.
Solution 9:
if [ $# -ne 0 ]; then #if condition to check if arguement is passed or not
directory1=$1
cd $directory1
if [ -d "Data" ]; then #if condition to check if direcotry exists or not
echo directory already exists
echo Type c to cancel and o to overwrite the directory
read varname
if [ $varname == o ]; then #if ocndition to check if o is pressed or not
cd Data
mkdir Image #overwriting directory
mkdir Cache
fi
else
mkdir Data #making directory
cd Data
mkdir Image
mkdir Cache
fi
else
echo arguements not supplied #print statement
fi