nixCraft Linux Forum

nixCraft

Linux / UNIX 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 ...

Register free or login to your existing account and remove all advertisements.


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

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-17-2006, 11:36 AM
Member
User
 
Join Date: Jun 2005
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
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
  #2 (permalink)  
Old 11-17-2006, 12:35 PM
Member
User
 
Join Date: Jun 2005
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
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, 12:41 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
OS: Debian GNU/Linux
Posts: 506
Thanks: 0
Thanked 8 Times in 6 Posts
Rep Power: 7
monk has a spectacular aura about monk has a spectacular aura about
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, 03:33 PM
Member
User
 
Join Date: Jun 2005
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
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, 01:56 AM
rockdalinux's Avatar
Is that all you got?
User
 
Join Date: May 2005
Location: Planet Vegeta
OS: Redhat
Posts: 695
Thanks: 15
Thanked 19 Times in 18 Posts
Rep Power: 10
rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light
Default

wOOt
__________________
Rocky Jr.
What's wrong? I hope I am not making you uncomfortable...

Never send a boy to do a mans job.
Reply With Quote
Reply


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 Off


Similar Threads

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


All times are GMT +5.5. The time now is 08:49 PM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

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 37 38