LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-03-2013, 02:52 AM   #1
MG00711
LQ Newbie
 
Registered: Feb 2013
Distribution: Linux Mint
Posts: 12

Rep: Reputation: Disabled
Making a script which halts for visual countdown, then continues the next command


This is what I have....


#!/bin/bash

etherwake 00:00:00:00:00:00

# This is where I need the code. Essentially all I am trying to do is wake my other computer,
# wait for it to boot, then login through vnc via http, I know there is a simple command to wait
# a certain amount of time, but I would like a countdown... Thanks in advance!

xdg-open http://192.168.1.101:5800
 
Old 02-03-2013, 04:08 AM   #2
ChooseLife
Member
 
Registered: May 2007
Distribution: Ubuntu, RHEL, Slackware
Posts: 49

Rep: Reputation: 17
Simple count-down with 1-sec delay:
Code:
for i in {10..0}; do echo -n $i... && sleep 1; done
 
Old 02-03-2013, 05:20 AM   #3
MG00711
LQ Newbie
 
Registered: Feb 2013
Distribution: Linux Mint
Posts: 12

Original Poster
Rep: Reputation: Disabled
while that code works, it does not work in my code. I want the countdown to finish before the browser launches, also I don't need all those numbers on the screen, I am looking for a ticker... similar to the countdown of the reboot process of dd-wrt router firmware in purpose...

Last edited by MG00711; 02-03-2013 at 05:28 AM.
 
Old 02-03-2013, 05:50 AM   #4
ChooseLife
Member
 
Registered: May 2007
Distribution: Ubuntu, RHEL, Slackware
Posts: 49

Rep: Reputation: 17
Quote:
Originally Posted by MG00711 View Post
I want the countdown to finish before the browser launches
this code should work for that. it effectively introduces a 10-second delay with visual feedback before moving on to the next portion of the script.

Quote:
Originally Posted by MG00711 View Post
also I don't need all those numbers on the screen, I am looking for a ticker... similar to the countdown of the reboot process of dd-wrt router firmware in purpose...
i'm not familiar with dd-wrt countdown, perhaps you can further explain what you want?
 
Old 02-03-2013, 06:09 AM   #5
MG00711
LQ Newbie
 
Registered: Feb 2013
Distribution: Linux Mint
Posts: 12

Original Poster
Rep: Reputation: Disabled
dd-wrt is replacement firmware which you can use on many different home routers that introduces many more advanced features than normally comes with it, one of them being a wireless bridge feature.. but the nice part is that if you are in the web gui and click its' reboot link, it brings you to a page where it counts down until a time when it thinks the router is finished rebooting, then refreshes.
obviously I'm not making a webpage, but I want my script to count down from about a minute or 2 after it runs my wake-on-lan command, and then launch the web gui for the vnc server hosted on the machine I woke up.
 
Old 02-03-2013, 06:16 AM   #6
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,461

Rep: Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368Reputation: 1368
A small adjustment.
Code:
for number in {10..1}; do echo -en "  \x0D$number" && sleep 1; done
 
1 members found this post helpful.
Old 02-03-2013, 06:21 AM   #7
MG00711
LQ Newbie
 
Registered: Feb 2013
Distribution: Linux Mint
Posts: 12

Original Poster
Rep: Reputation: Disabled
actually I found that it does work (launched from terminal) my mistake, but it doesn't work when I double click on the script, how do I fix that?
 
Old 02-03-2013, 07:01 AM   #8
ChooseLife
Member
 
Registered: May 2007
Distribution: Ubuntu, RHEL, Slackware
Posts: 49

Rep: Reputation: 17
Quote:
Originally Posted by MG00711 View Post
dd-wrt is replacement firmware...
yeah, i know what it is, used it some years ago, just not familiar with its countdown.

Quote:
Originally Posted by MG00711 View Post
actually I found that it does work (launched from terminal) my mistake, but it doesn't work when I double click on the script, how do I fix that?
how specifically does it not work when you double-click it? do you have the execution bit set?
 
Old 02-03-2013, 11:14 AM   #9
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,667
Blog Entries: 10

Rep: Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076
bash countdown timer:
Code:
MIN=1 && for i in $(seq $(($MIN*60)) -1 1); do echo -n "$i, "; sleep 1; done; echo -e "Message"
or substitute
Code:
notify-send -i "Message"
after "done;" for a visual reminder via the notification area.
 
Old 02-04-2013, 06:35 AM   #10
MG00711
LQ Newbie
 
Registered: Feb 2013
Distribution: Linux Mint
Posts: 12

Original Poster
Rep: Reputation: Disabled
it starts running throught my script, does the wake-on-lan, displays a part of the command, but not long enough for me to read through it all before the terminal closes, I think this is the part I see "\x0D$number" and then the window closes, no countdown...

my code is this:

#!/bin/bash
sudo etherwake 00:00:00:00:00:00
for number in {50..1}; do echo -en " \x0D$number" && sleep 1; done
xdg-open http://192.168.1.101:5800

my script is executable, and when I run it from within terminal, it wakes the machine, counts 50 seconds, then launches the web gui at 192.168.1.101:5800 just fine.... If I double click the file, which is on the desktop, it wakes the machine, then displays something like "\x0D$number" then terminal closes...

Last edited by MG00711; 02-04-2013 at 06:40 AM.
 
Old 02-04-2013, 08:28 AM   #11
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,667
Blog Entries: 10

Rep: Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076
Quote:
Code:
#!/bin/bash
sudo etherwake 00:00:00:00:00:00
for number in {50..1}; do echo -en "  \x0D$number" && sleep 1; done
xdg-open http://192.168.1.101:5800
If you know it takes ~60s then just 'wait' 60s (using sleep 60s) and lose the echo.

Code:
#!/bin/bash
sudo etherwake 00:00:00:00:00:00
sleep 60s
xdg-open http://192.168.1.101:5800
where did this snippet come from?
Quote:
for number in {50..1}; do echo -en " \x0D$number
Do you really need to "see a countdown timer" on a desktop script file that runs terminal and you know it takes about 60s?
 
Old 02-04-2013, 10:40 PM   #12
MG00711
LQ Newbie
 
Registered: Feb 2013
Distribution: Linux Mint
Posts: 12

Original Poster
Rep: Reputation: Disabled
No, I don't really NEED any script, I could do it all manually, but since I am new to Linux, learning how to do it could help with other things later, and why would I not bother just because it may be easier the other way? With that mentality I may as well just stick to windows... making these dumb little scripts may seem silly but when I barely know the system, every bit helps...
 
Old 02-05-2013, 09:40 AM   #13
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,667
Blog Entries: 10

Rep: Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076Reputation: 2076
I would never question your making a choice,
but I tend to wonder about the choice that was made sometimes when I see a challenge.

I certainly didn't intend to make you upset.

I'd try:
Code:
#!/bin/bash
sudo etherwake 00:00:00:00:00:00
for number in {60..1}; do echo -en "$number " && sleep 1; done
xdg-open http://192.168.1.101:5800
this will "move" the timer and populate it horizontally across the screen.

and this will leave it next to the prompt but countdown ala digital timer:
Code:
#!/bin/bash
sudo etherwake 00:00:00:00:00:00
for number in {60..0}; do clear && echo -en "$number " && sleep 1; done
xdg-open http://192.168.1.101:5800
There's a quirk about for loops in bash and/or scripts, but I don't remember exactly.
http://mywiki.wooledge.org/BashPitfalls

Post your progress, if any and keep looking "Under the Hood"!

subscribed with interest,
JJ
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Intel Continues Making Wayland Tablet-Friendly LXer Syndicated Linux News 0 09-26-2012 05:30 AM
Odd problem with making a variable the output of a command in a shell script linux=future Programming 3 12-13-2005 10:45 PM
Making Emacs more like Visual Studio MDBlueIce Linux - Software 0 06-24-2005 11:49 AM
command line args in a countdown Squeak2704 Programming 1 04-26-2004 01:27 PM
kernel halts, system halts, computer commits suicide stupid_guy Linux - Newbie 10 06-07-2003 06:44 PM


All times are GMT -5. The time now is 12:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration