0

I am trying to execute a script and its throwing "File Not Found" error. Below is my script

#!/usr/bin/ksh export ROOT_ENV=dev export ROOT_DIR=/files/$ROOT_ENV/windows/mp export SRC_DIR=$ROOT_DIR/mp1 mail_id='[email protected]' if [[ -e "$SRC_DIR"/*_PO ]] then echo "File exist" exit 0 else echo "File not found" exit 1 echo "Hello User, File does not exist in the "$SRC_DIR". Please place the file in the path : "$SRC_DIR" Thanks, Team " | mail -s "Warning: <"$ROOT_ENV="> <INFA> <PACK> FILE DOES NOT EXIST in path '$SRC_DIR'" $mail_id echo "File does not exist" fi done 

Appreciate if some one can help here. Thanks,

4
  • ksh scripts are not bash scripts. Tag ksh, use ksh in the title. Commented Dec 3, 2020 at 23:31
  • Beyond that -- make sure your code is a minimal reproducible example, the shortest possible thing that exits with the same error. If it has the same error when you take out the "mail_id" assignment, for example, then you should take out that assignment. Commented Dec 3, 2020 at 23:33
  • And beyond that, [[ -e "$SRC_DIR"/*_PO ]] isn't going to work as you expect. A glob expression can't be used in a context that expects only exactly one file. Commented Dec 3, 2020 at 23:33
  • ...to the extent that that's your problem, it's a duplicate of check if a file exists with wildcard in shell script, as discussed in BashFAQ #4. Commented Dec 3, 2020 at 23:34

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.