Find the answer to your Linux question:
Results 1 to 8 of 8
Hi guys I'm new to scripting in Linux but I need a help urgently. I need to know how to delay a command execution? for example a delay of 10 ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    11

    Exclamation Scripting

    Hi guys I'm new to scripting in Linux but I need a help urgently. I need to know how to delay a command execution? for example a delay of 10 seconds before a command line is executed! I need this help very urgently.. I would appreciate any notes or even commands that would help me


    Thanks guys

  2. #2
    Linux Newbie
    Join Date
    Nov 2007
    Location
    Planet Earth
    Posts
    152
    The sleep command, e.g.:

    $ sleep 5

    delays 5 seconds the next sentence.
    EOF

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Posts
    11
    does it work with .sh files?

  4. #4
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    try it, then you know if it works.

  5. #5
    Just Joined!
    Join Date
    Jan 2009
    Posts
    11
    I don't know why am i getting error in this message. can anyone please clear me out.

    thanks guys

    #!/bin/bash

    for stress in `seq 10`
    do
    echo "Running the stress test now"
    read -p "Entering S3 mode now. Press ENTER once ready"
    echo -n "mem">/sys/power/state
    echo "Wake up from S3 is successful"
    $sleep 10
    read -p "Entering S1 mode now. Press ENTER once ready"
    echo -n "standby">/sys/power/state
    echo "Wake up from S1 is successful"
    echo "Looping back"
    done
    exit 0

  6. #6
    Just Joined!
    Join Date
    Jan 2009
    Posts
    11

    Exclamation

    I am getting the error below. Guys i need this help very urgently.. thanks

    : command not foundline 2:
    : command not foundline 4: do
    Running the stress test now
    Entering S3 mode now. Press ENTER once ready
    : No such file or directory/sys/power/state
    Wake up from S3 is successful
    : command not foundline 9: 10
    Entering S1 mode now. Press ENTER once ready
    : No such file or directory /sys/power/state
    Wake up from S1 is successful
    Looping back
    : command not foundline 14: done
    : numeric argument required exit: 0

  7. #7
    Just Joined!
    Join Date
    Jan 2009
    Posts
    11

    Smile

    Guys.. after checking here is the code. Could you guys check whether there is any problem with my script as the execution of the command has some problem.

    #!/bin/bash

    #for stress test in `seq 10`
    do
    echo "Running the stress test now";
    read -p "Entering S3 mode now. Press ENTER once ready";
    echo -n "mem">/sys/power/state;
    echo "Wake up from S3 is successful";

    sleep 10;

    read -p "Entering S1 mode now. Press ENTER once ready";
    echo -n "standby">/sys/power/state;
    echo "Wake up from S1 is successful";
    echo "Looping back";
    done;
    exit 0;



    thank you guys for the help

  8. #8
    Just Joined!
    Join Date
    Mar 2008
    Location
    Chennai, India
    Posts
    26

    Is this a homework??

    Quote Originally Posted by unrevealed01 View Post
    Guys.. after checking here is the code. Could you guys check whether there is any problem with my script as the execution of the command has some problem.
    Do it yourself.
    Test your script with "-xv" option in the shabang or try this while executing your script:

    $ bash -xv <your_script_name>

    You should test your codes and scripts and post the problems here.

    Quote Originally Posted by unrevealed01 View Post
    thank you guys for the help
    Nothing is for free here!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...