Simple Script?

Discussion in 'Web Design & Coding' started by Bretenn, Oct 9, 2002.

  1. Bretenn

    Bretenn Guest

    do u guys know how to write a script that produce an endless loop of a word (a simple script) in unix?

    Sory, i'm a newbee to unix
     
  2. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    not sure how you mean... do you mean you want to run a command over and over?
     
  3. Bretenn

    Bretenn Guest

    sory... i want to write a script that can run an endless loop (continuous loop) on the screen. (UNIX)

    e.g. Edless loop of a word "speak".
    [screen]
    speak
    speak
    speak
    speak
    speak
    ...
     
  4. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    you can try the "echo" command
    either put this in a file:
    Code:
    echo speak
    echo speak
    echo speak
    echo speak
    echo speak
    echo speak
    
    but thats obviously limited to however many times you write out the line, you could make the file write the word then run itself again, giving an indefinate endless loop:
    (for file name "echoscript")
    Code:
    echo speak
    echoscript
    
    im not sure if theres some sort of loop or goto command, hope this has helped tho...
     
  5. Bretenn

    Bretenn Guest

    can u explain a bit detail?? sory!!
     
  6. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    well, the echo command does literly that, it echo's onto the screen like so....
    So if you where to put that command into a file like this
    Code:
    echo hello
    echo hello
    echo hello
    echo hello
    echo hello
    echo hello
    echo hello
    
    then it will echo it that many times....
     
  7. DrMetallica

    DrMetallica OSNN Senior Addict

    Messages:
    301
    man i just did the code for a loop in c++ today but i forgot it.

    Code:
    for (int x)
    {
    MessageBeep(0xFFFF);
    MessageBeep(0xFFFF);
    MessageBeep(0xFFFF);
    MessageBeep(0xFFFF);
    MessageBeep(0xFFFF);
    }
    Is this correct?
     
  8. Zedric

    Zedric NTFS Guru Folding Team

    Messages:
    4,006
    Location:
    Sweden
    I'd use
    Code:
    while (true)
    {
    MessageBeep(0xFFFF);
    }
    instead
     
  9. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    yes speak

    will repeat the word speak on screen over and over forever.
     
  10. MadHaXX()|2

    MadHaXX()|2 Guest

    first of all, you have several shells in unix/linux its not like dos where there is only one way to do it. personally i'd use perl

    cut & paste whats between the 2 dotted lines (dont actually include them in gthe prog)
    ---------------------------------------------------------
    #!/usr/bin/perl

    while(true)
    {
    print "place text here\n";
    }
    ---------------------------------------------------------
    make sure #!/usr/bin/perl is on the 1st line else it'll fu.ck up

    then save the file, on the command line type chmod 755 (or 777) filename.
    to execute it be in the directory and type ./filename

    there ya go!