I wanted to write the commands as a conditional statement for if i.e., when the command executes without any error it should print success and failure if it fails. I'm even trying to prevent from printing the long console messages of the commands. Below is the code that I'm using, which is working perfectly without any conditional statements like printing success or failures messages.
$(BASENAME).pdf: $(BASENAME).ps
ps2pdf $(BASENAME).ps $(BASENAME).pdf
$(BASENAME).ps: $(BASENAME).dvi
dvips -Ppdf $(BASENAME).dvi -o $(BASENAME).ps
I tried changing above as
$(BASENAME).pdf: $(BASENAME).ps
@out=ps2pdf $(BASENAME).ps $(BASENAME).pdf > /dev/null 2>&1 && echo " 5. ps2pdf successful" || echo " 5. ps2pdf failed"
$(BASENAME).ps: $(BASENAME).dvi
dvips -Ppdf $(BASENAME).dvi -o $(BASENAME).ps > /dev/null 2>&1\
if [ $? -eq 0 ];\
then \
echo " 4. dvips successful";\
else \
echo " 4. dvips failed";\
exit 2;\
fi
which is failing my execution and providing me error while running the code like below error
dvips -Ppdf basename_04.dvi -o basename_04.ps \
if [ basename_04.dvi -eq 0 ];\
then \
echo " 4. dvips successful";\
else \
echo " 4. dvips failed";\
exit 2;\
fi
/bin/sh: -c: line 2: syntax error near unexpected token `then'
/bin/sh: -c: line 2: ` then \'
make: *** [basename_04.ps] Error 1
Even after updating with semi-colon, I'm getting below error.
dvips -Ppdf nkukunur_04.dvi -o nkukunur_04.ps > /dev/null 2>&1 ;\
if [ nkukunur_04.dvi -eq 0 ]; \
then \
echo " 4. dvips successful"; \
else \
echo " 4. dvips failed"; \
exit 2; \
fi
/bin/sh: line 1: [: nkukunur_04.dvi: integer expression expected
4. dvips failed
Please help me in fixing the issue.