Hi there --
I have a script running on one of our workstations that converts .ps files to .pdf versions using the ps2pdf binary. The text of the script is shown below:
Code:
#!/bin/bash
# The purpose of this script is to go to the directory in question,
# and convert all postscript, .ps, files located there to .pdf files.
# Provide a list of the cases directory for the user.
cd /home/rsa/data/xknife_data/cases
echo CONVERSION OF POSTSCRIPT, .ps, FILES TO ADOBE ACROBAT, .pdf, FORMAT.
echo
echo
echo The patients in the cases folder will now be listed for your convenience.
echo
echo It is important that you make note of the exact spelling of the directory
echo in question in order for this process to work.
echo
echo
read -p "Press the enter key to continue..."
ls -1 | more
echo
echo
echo Please enter the directory that is the object of this exercise.
echo If you make a mistake here, hit CTRL-C to exit from the script,
echo and start over.
echo
read directory
echo Is $directory the patient in question?
if [ -e $directory ]
then
echo "Patient directory found."
else
echo "Patient directory NOT found."
fi
# Change to the directory in question
cd /home/rsa/data/xknife_data/cases/$directory
# Copy the .ps files to a local directory
cp -pr *.ps /tmp/ps2pdf
# Change to the temporary directory
cd /tmp/ps2pdf
# List the files that were copied over the temporary directory
ls -l
# Convert the files in the temporary directory to .pdf format.
for i in *.ps;
do ps2pdf "$i";
done
# Copy the .pdf files back to the original location
cp -pr *.pdf /home/rsa/data/xknife_data/cases/$directory
# Remove the files from the temporary directory
cd /tmp/ps2pdf
rm -rf *.ps
rm -rf *.pdf
echo The conversion of the postscript files to acrobat format is complete.
echo Use an ftp client application to retrieve the files from the patient directory.
I have been asked to add the following improvements to the script:
1. Enable the ability for the users to highlight the name of the directory of those listed, and then copy, and subsequently paste the name of it when prompted by the script.
2. Allow users to be able to backspace and correct the spelling of the directory when entering it at the prompt.
3. Allow users to reenter the name of the directory if they discover its spelling was typed in incorrectly at the prompt.
The first item is not absolutely necessary, although it would be nice to have available. The second and third items would be of great benefit to have.
I am not familar with the correct syntax to enable the items that I listed, so I was hoping someone could lend a hand here. Thanks.