nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

displaying the executed command then echo the status

This is a discussion on displaying the executed command then echo the status within the Shell scripting forums, part of the Development/Scripting category; Hi, I have a simple question for everyone. I just need only to format a device then mount. heres the ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 11-17-2006, 12:36 PM
Member
User
 
Join Date: Jun 2005
Posts: 45
Rep Power: 0
warren
Default displaying the executed command then echo the status

Hi,

I have a simple question for everyone. I just need only to format a device then mount. heres the sample code:

echo "formatting /dev/$dev ....mkfs.ext3 /dev/$dev"
mkfs.ext3 -Fq /dev/$dev
mount /dev/$dev /mnt/$dev

I would like to modify it that will display a msg after the task is completed. Like:
formatting /dev/sda.............................................[done]

If format fails, then "failed" will be displayed. my problem is how to display this in a single line just like in above.
any ideas are greatly welcome.

thanks,
warren
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-17-2006, 01:35 PM
Member
User
 
Join Date: Jun 2005
Posts: 45
Rep Power: 0
warren
Default

ok i see, there's an command named "action". i think this will work.
Reply With Quote
  #3 (permalink)  
Old 11-17-2006, 01:41 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Try something as follows:

Code:
echo ""
echo -n "formatting /dev/$dev ....mkfs.ext3 /dev/$dev"
mkfs.ext3 -Fq /dev/$dev > /dev/null
mount /dev/$dev /mnt/$dev  > /dev/null
[ "$?" == "0" ] &&  echo -n " ... DONE!" || echo -n " ...  Failed!"
echo ""
Reply With Quote
  #4 (permalink)  
Old 11-28-2006, 04:33 PM
Member
User
 
Join Date: Jun 2005
Posts: 45
Rep Power: 0
warren
Default

thanks so much monk
yes it works. It helps a lot...

warren
Reply With Quote
  #5 (permalink)  
Old 11-29-2006, 02:56 AM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 581
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

wOOt
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
hda: status timeout: status=0xd0 { Busy } surmandal Linux hardware 3 03-24-2008 09:16 PM
UNIX / Linux echo command examples raj Getting started tutorials 2 12-07-2007 12:20 PM
avoid displaying errors while executing a script vikas027 Shell scripting 4 10-31-2007 12:57 PM
Rateuo.c can not be executed Oznur Linux software 3 09-16-2005 03:31 PM
exit status Shell scripting 8 09-02-2005 07:34 PM


All times are GMT +5.5. The time now is 09:04 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36