0

im gong to compile oracle forms on Solaris and create a script. the script should check if .fmx is created then removes .err file. here is my script but I've received below error

Code to remove error files

export FORMS_PATH=export FORMS_PATH=/apps/apps/frmcompile/cmteam/hla
for FILE in `ls $FORMS_PATH/*.fmx`; do  

    if exist "$FILE/*.fmx"; 
    then 
        rm $FILE/err
    fi
done

Error Encountered

rmerr.sh[3]: exist: not found [No such file or directory]

2
  • Please take a look: shellcheck.net Commented Aug 11, 2016 at 5:17
  • You should better explain what you precisely want to do. Even after correcting the shell programming mistakes, the logic of your script is flawed. Commented Aug 11, 2016 at 9:23

3 Answers 3

1

Regular File test is done using "-f"

export FORMS_PATH=export FORMS_PATH=/apps/apps/frmcompile/cmteam/hla
for FILE in `ls $FORMS_PATH/*.fmx`; do  
    # True if file exists and is a regular file.
    if [ -f "$FILE/*.fmx"]; then 
        rm $FILE/err
    fi
done
Sign up to request clarification or add additional context in comments.

Comments

1

This might be what you want to do, but it is unclear where .fmx and .err files are located:

export FORMS_PATH=/apps/apps/frmcompile/cmteam/hla
for FILE in $FORMS_PATH/*.fmx; do
    b=$(basename $FILE)
    [ -f "$b" ] && rm ${b%fmx}err
done

Comments

1

".err" is a file, but you list "err" here. Some other problem here:

  1. export FORMS_PATH=export FORMS_PATH=/apps/apps/frmcompile/cmteam/hla

    Replace with "FORMS_PATH=/apps/apps/frmcompile/cmteam/hla"

    1. for FILE in ls $FORMS_PATH/*.fmx; do FILE contains every file ending in ".fmx"
    2. if exist "$FILE/.fmx"; Result eg in "/apps/apps/frmcompile/cmteam/hla/blaba.fmx/.fmx" with shell expansion and "exist" - what's this - try "test" or "[]".
    3. rm $FILE/err Results in "/apps/apps/frmcompile/cmteam/hla/blaba.fmx/err or .err in subfolder and that you don't like, or?

So best use this:

#!/bin/sh     OR #!/bin/bash
FORMS_PATH=/apps/apps/frmcompile/cmteam/hla

for fmx in $FORMS_PATH/*.fmx; do  

   # remove your files ending in .err instead of .fmx 
   /bin/rm "${fmx%.fmx}.err    # only valid with bash

done

Tom

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.