Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have no idea why my code is not working, please help me see whats the problem

ID: 3545242 • Letter: I

Question

I have no idea why my code is not working, please help me see whats the problem when i run it it says line 6: no such directory found and line 46!

#! /bin/bash

IFS=" "

count=0

rm -rf ${HOME}/mail_split/*

function process_header () {

flag=0

read first rest

while [ "$first $rest" != " " ] ; do

if [ "$rest" == "URGENT" ] ; then

flag=1

fi

        case "$first" in                 "Date:")                 echo $first $rest                 :                 ;;                 "From:")                 echo $first $rest                 :                 ;;                 "To:")                 echo $first $rest                 :                 ;;                 "Subject:")                 echo $first $rest                 :                 ;;         *)         ;;         esac         read first rest done >> mail_split/$count process_body }

function process_flag () { if [ $flag -eq 1 ] ; then         cat ./mail_split/$count | mail -s "URGENT" 8182945919@txt.att.net fi count=$(( count + 1)) process_split }

function process_body () { read first rest while [ "$first $rest" != " " ] ; do         echo $first $rest;         read first rest done >> mail_split/$count process_flag }

function process_split () { read first rest while [ $? -eq 0 -a "$first" == "From" ] ; do         process_header         #process_flag         #return 1         echo "" done } process_split exit

Explanation / Answer

there are 3 possible ways to fix this.


1) remove ${HOME} and use $HOME

2) or you might be missing the '/' at the begining --- /${HOME} or /$HOME

3) Instead of using ${HOME} please run cd $HOME at the command prompt and you will be redirected to home directory and then run the command pwd - it will show you the present working directory. Copy that location and use it in the shell script.