Commands to start and stop a job using Shell Script

My shell program is supposed to do the following:
1.  switch user: su - sasadm.
2. decode: DB_PASSWORD
3. run a command line process that start and stop a job
4. print out sas processes that are run to a log (based on the sas.server  stop command)
5. give the user the option to start or stop jobs:
6. print out sas that have stop to a log (based on the sas.server  stop command)

When I start and stop the job from the command line, I do the following:

$ ./sas.server start  ---- it prints out to the terminal sas processes that are started

$ ./sas.server  stop ---- it prints out to the terminal sas processes that have stopped

Here is my code: It is not working:

file name that stores password:db_auth.cfg

DB_PASSWORD=Z29vZ2xl

#!/bin/bash
echo "hello"
su - sasadm <<EOF
source path_to_the_file/db_auth.cfg
DB_PASSWORD=$(eval echo ${DB_PASSWORD} | base64 --decode)
echo Now I am sasadm
id                                                                      
echo "yes!"
EOF
whoami

runbatch –f /sasem/sas94m2/config/Lev1 || exit 0
case “$1” in
    start)
           echo –n “$./sas.server ”
            /sasem/sas94m2/config/Lev1
           cat <<EOF > file1
            ;;
   stop)
          echo –n “$./sas.server”
          /sasem/sas94m2/config/Lev1
         cat <<EOF > file2
           ;;
 
        *)
          echo “Usage: / start|stop|”
          exit 1
          ;;
    esac
dfn48Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Murugesan NagarajanCommented:
Hi,

The following line has error:
Replace:
cat <<EOF > file1

Open in new window

.
.
cat <<EOF > file2

Open in new window

With:
cat <<EOF > file1
Write the message you need to overwrite into the file file1
EOF

Open in new window

.
.
cat <<EOF >> file2
Write the message you need to append
As per your requirement you can use overwrite or append into the file file2
EOF

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.