Skip to contentSkip to conversation

bash script problem

DISCUSSION Daniel Peter Cavanagh 4 participants 4 messages Dec 10, 2002

lore
Share & tools
lore
#0 lore raw

Hi,

I'd like to write a script that will run a command, and if successful run another command otherwise echo a message.

This is what I have but it doesn't work (I've never written a bash script before):

if [ fetchmail -su nofsk pop.vtown.com.au ]; then
pine
else
echo failed fetch
fi

Could something please fix this up. Thanks for your help, Daniel.

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#1 lore raw
Quoted 4 lines · Daniel Peter Cavanagh

I'd like to write a script that will run a command, and if successful run another command otherwise echo a message.

How about this:
------------------------------------
fetchmail -su nofsk pop.vtown.com.au

case $? in 0) pine;;
           *) echo failed fetch;;

esac
------------------------------------

Cheers,
Steven

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#3 lore raw
In reply to Daniel Peter Cavanagh

Try this:

fetchmail -su nofsk pop.vtown.com.au && pine || echo failed fetch

see if that works for you.

--Brian Jackson

Quoted 12 lines · Daniel Peter Cavanagh

Hi,

I'd like to write a script that will run a command, and if successful run another command otherwise echo a message.

This is what I have but it doesn't work (I've never written a bash script before):

if [ fetchmail -su nofsk pop.vtown.com.au ]; then
pine
else
echo failed fetch
fi

Quoted 7 lines

Could something please fix this up. Thanks for your help, Daniel.

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#2 lore raw
In reply to [email protected]

Check this bash script for me, please.

#/bin/sh
#

# if a floppy can be formatted 1.68 megabytes
#    with 0 bad blocks
# else
#    format 1.44 megabytes
# fi
# mkfs.msdos /dev/fd0
#
if   (superformat /dev/fd0u1680 && badblocks -c 512 -n /dev/fd0u1680);
then
     mkfs.msdos /dev/fd0u1680
else superformat /dev/fd0u1440 
     mkfs.msdos /dev/fd0u1440
fi
mdir
#

I'm thinking that 'badblocks' can find bad blocks and still return
a 'true' condition. If this is true, is there any way to cause the smaller format?

If 'superformat /dev/fd0u1680' fails, it drops back to '/dev/fd0u1440'.

Regards, Chuck
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs