LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-21-2004, 01:03 PM   #1
jeopardyracing
Member
 
Registered: Sep 2003
Posts: 175

Rep: Reputation: 30
Delay in shell script or alias


I need to put a delay in a shell script (or maybe a command line alias).

Here's what I need to do: in order to enable my wifi card on my Fell in Fedora Core 2, I need to first DISABLE the device, then wait, then enable (don't ask). But I need a delay in the script so the card has a moment to react:

#!/bin/bash

rcstop
[insert delay here]
rcstart

[end script]

also, instead of doing this as a shells script, can I create an alias so all I need to do is type one word? If so, how do I make an alias with more than one line?

Also, do I understand correctly that the alias can go in

~/.bashrsc

(I may have misspelled that directory, but is that the idea?)
 
Old 09-21-2004, 01:17 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
You can create a pause (for example 5 seconds) with:
sleep 5

You should only need to type one word regardless of whether you use an alias or a script that sits in your PATH.
 
1 members found this post helpful.
Old 09-21-2004, 01:38 PM   #3
jeopardyracing
Member
 
Registered: Sep 2003
Posts: 175

Original Poster
Rep: Reputation: 30
location of Alias

Thanks so much - do I have the procedure right (and the file in particular) for creating the alias?
 
Old 09-21-2004, 01:48 PM   #4
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
here's what you'd want to do:

Code:
#!/bin/bash
#This is a script to restart your wireless nic
#Let's assume this script will be named wireless
rcstop
sleep 5
rcstart
exit
#EOF
So - we now have a script called wireless
we'll need to make it executable, so we:
Code:
# chmod o+x wireless
now, put it in /bin so you can execute it wherever you are
Code:
# mv ./wireless /bin
Now try it:
Code:
$ wireless
 
Old 09-21-2004, 02:13 PM   #5
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
if you are into the alias way.
A script is better to me though.

Code:
alias wireless="rcstop; sleep 5; rcstart"
 
Old 09-21-2004, 04:08 PM   #6
jeopardyracing
Member
 
Registered: Sep 2003
Posts: 175

Original Poster
Rep: Reputation: 30
Awesome!

Hey, thanks a ton for the tips. I will note both since both will be very helpful!
 
Old 09-21-2004, 08:07 PM   #7
jeopardyracing
Member
 
Registered: Sep 2003
Posts: 175

Original Poster
Rep: Reputation: 30
worked great

Those tips worked great. Now I can reset the wifi card with one command. Thanks again, you guys rock.

Now if only creating bash aliases were as easy on my mac (OS X)! It's not nearly as simple there....
 
  


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
Shell Redirection Delay pymehta Linux - Software 10 07-22-2009 07:31 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
how-to: repeat OR iterate shell OR bash command delay OR interval admarshall Linux - General 5 07-18-2005 10:47 PM
alias in bash shell wincrk Linux - General 12 07-20-2004 12:35 PM
RH9, alias and tcsh shell jeguilloal Red Hat 1 11-26-2003 01:42 PM


All times are GMT -5. The time now is 01:40 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration