nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

repeat command is missing

This is a discussion on repeat command is missing within the Shell scripting forums, part of the Development/Scripting category; hey i wanna repeat 3 echo hello world. but command not found is there a link or something for missing ...


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 28-06-2009, 01:55 AM
eawedat's Avatar
Senior Member
User
 
Join Date: May 2008
Location: Palestine
OS: Kn0ck3D
Posts: 132
Thanks: 1
Thanked 2 Times in 2 Posts
Rep Power: 2
eawedat is on a distinguished road
Send a message via MSN to eawedat
Smile repeat command is missing

hey
i wanna
repeat 3 echo hello world.

but command not found
is there a link or something for missing files(linux)


thanks
__________________
Be to be and not to pee
Reply With Quote
  #2 (permalink)  
Old 28-06-2009, 07:18 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,706
Thanks: 11
Thanked 243 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

How about?
PHP Code:
for i in 1 2 3
do
   echo 
"Hello $i times"
done 
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 28-06-2009, 12:15 PM
eawedat's Avatar
Senior Member
User
 
Join Date: May 2008
Location: Palestine
OS: Kn0ck3D
Posts: 132
Thanks: 1
Thanked 2 Times in 2 Posts
Rep Power: 2
eawedat is on a distinguished road
Send a message via MSN to eawedat
Smile

thanks nixcraft
sorry but the idea was really related to do that thing with repeat file

thanks anyway..
__________________
Be to be and not to pee
Reply With Quote
  #4 (permalink)  
Old 02-07-2009, 08:30 AM
Member
User
 
Join Date: May 2009
OS: Mandriva
Posts: 78
Thanks: 0
Thanked 14 Times in 14 Posts
Rep Power: 2
cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about
Default

Repeat is not a standard command. However, it is trivial to implement.

Put this in a file called repeat, make it executable and put it in a directory in your PATH:

Code:
n=$1
shift
while [ $(( n -= 1 )) -ge 0 ]
do
  "$@"
done
Once you've done that, you have a repeat command.
Reply With Quote
  #5 (permalink)  
Old 02-07-2009, 12:49 PM
eawedat's Avatar
Senior Member
User
 
Join Date: May 2008
Location: Palestine
OS: Kn0ck3D
Posts: 132
Thanks: 1
Thanked 2 Times in 2 Posts
Rep Power: 2
eawedat is on a distinguished road
Send a message via MSN to eawedat
Smile hey

hey Johnson
thanks for helping
but sorry to say that your script does not work fine.
__________________
Be to be and not to pee
Reply With Quote
  #6 (permalink)  
Old 02-07-2009, 12:56 PM
Member
User
 
Join Date: May 2009
OS: Mandriva
Posts: 78
Thanks: 0
Thanked 14 Times in 14 Posts
Rep Power: 2
cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about
Default

Quote:
Originally Posted by eawedat View Post
hey Johnson
thanks for helping
but sorry to say that your script does not work fine.

What does "does not work fine" mean?

What does happen? What's wrong with it?

What was the exact script you used? How did you execute it?
Reply With Quote
  #7 (permalink)  
Old 02-07-2009, 01:08 PM
eawedat's Avatar
Senior Member
User
 
Join Date: May 2008
Location: Palestine
OS: Kn0ck3D
Posts: 132
Thanks: 1
Thanked 2 Times in 2 Posts
Rep Power: 2
eawedat is on a distinguished road
Send a message via MSN to eawedat
Default bin bash

first
1) cat repeat
2)added #!/bin/sh at first line(am not sure if this is needed)
even without it ,, it does not work..
2) ctrl + x , yes
3) chmod 777 repeat
4) ./repeat echo hi
5) repeat echo hi
nothing happens
u still get the prompt
__________________
Be to be and not to pee
Reply With Quote
  #8 (permalink)  
Old 02-07-2009, 06:09 PM
Member
User
 
Join Date: May 2009
OS: Mandriva
Posts: 78
Thanks: 0
Thanked 14 Times in 14 Posts
Rep Power: 2
cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about
Default

Quote:
Originally Posted by eawedat View Post
first
1) cat repeat

What is the output of cat repeat?
Quote:
2)added #!/bin/sh at first line(am not sure if this is needed)
even without it ,, it does not work..

You need to run it with a standard shell. On most systems, that is
/bin/sh, but on some it is elsewhere (e.g. Solaris is /usr/xpg4/bin/sh).
Quote:
2) ctrl + x , yes

What's that for?
Quote:
3) chmod 777 repeat

Use chmod 755. You should never make files world writable.
Quote:
4) ./repeat echo hi
5) repeat echo hi

That should be:

Code:
repeat 3 echo Hi
Quote:
nothing happens
u still get the prompt
Reply With Quote
Reply

Tags
bash , for loop , linux , shell scripting , unix


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
what am I missing? katsushiro Windows Xp/2000/2003 server administration 0 23-06-2009 08:37 PM
save command and command output savook CentOS / RHEL / Fedora 1 08-05-2009 05:33 PM
NPTL...MISSING in Centos !!!!!!!!!!! amsreeku Linux software 0 08-08-2008 03:10 AM
If error repeat the download? karabaja Shell scripting 3 10-10-2006 02:32 AM


All times are GMT +5.5. The time now is 04:49 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 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