Find the answer to your Linux question:
Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 21 to 30 of 33
I have tried the to add the following code line to sudoers: Code: my.username ALL=(ALL) NOPASSWD: ALL but it did not work. For the command: Code: ps -ef|egrep [scriptname] The ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #21
    Just Joined!
    Join Date
    May 2011
    Posts
    38

    I have tried the to add the following code line to sudoers:
    Code:
    my.username   ALL=(ALL) NOPASSWD: ALL
    but it did not work.

    For the command:
    Code:
    ps -ef|egrep [scriptname]
    The output was:
    Code:
    ebv       1808     1  0 01:03 ?        00:00:00 xterm -e /home/ebv/levmar-2.5/test.sh
    ebv       1819  1808  0 01:03 pts/0    00:00:00 /bin/bash /home/ebv/levmar-2.5/test.sh
    ebv       1885  1873  0 01:10 pts/1    00:00:00 egrep --color=auto test.sh

  2. #22
    Just Joined!
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    29
    Alright, this is the last ditch effort.

    It could be that when the job is being invoked, either by 'cron' or 'at', it does not have a proper path. As such, please append to your script the following example taken from the default system crontab file - /etc/crontab:
    Code:
    SHELL=/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:[path/to/your/script]
    Substitute
    Code:
    '[path/to/your/script]'
    in the PATH statement above with the proper path to where your script resides.

    You can also substitute
    Code:
    SHELL=/bin/sh
    with a shell of your choice.

    I really hope that's it!

    Ciao,
    ak.

  3. #23
    Linux User sgosnell's Avatar
    Join Date
    Oct 2010
    Location
    Baja Oklahoma
    Posts
    438
    #/etc/sudoers
    #
    # This file MUST be edited with the 'visudo' command as root.
    #
    # See the man page for details on how to write a sudoers file.
    #
    Read and heed "This file MUST be edited with the 'visudo' command as root."

    In a terminal run "man sudoers" and read the manual, especially the parts about using NOPASSWD. Once you understand that, run "sudo visudo" to edit the sudoers file. You just want to let yourself run your script without a password. Be careful with this, because you DO NOT want to let everyone run everything without a password.

  4. #24
    Just Joined!
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    29
    Quote Originally Posted by sgosnell View Post
    Read and heed "This file MUST be edited with the 'visudo' command as root."

    In a terminal run "man sudoers" and read the manual, especially the parts about using NOPASSWD. Once you understand that, run "sudo visudo" to edit the sudoers file. You just want to let yourself run your script without a password. Be careful with this, because you DO NOT want to let everyone run everything without a password.
    Indeed, that is very true. Just one quick question - would editing this file with visudo have caught the typo he made earlier whereby he locked himself out? Well, let me give it a try:
    * Login to 2 terminal sessions
    * sudo su on one terminal (this will ensure that should it lock me out, I can fix it w/o having to resort to recovery methods
    * sudo visudo on other terminal and remove the '%' like the OP did earlier
    * save the edited file

    Bummer, it saved the bloody file! So, even though visudo will check for syntax errors, it will not help you if you know NOT what you are doing! Read the FINE manual!

    Cheers,
    ak.

  5. #25
    Linux User sgosnell's Avatar
    Join Date
    Oct 2010
    Location
    Baja Oklahoma
    Posts
    438
    Well, duh! Linux, any flavor, assumes you know what you're doing when you work as root, and will let you do whatever you want. If you don't know what you're doing, you're best doing nothing. However, to learn you have to make mistakes, and break things. Fixing your borkage is the best way to learn, and it's always fixable, one way or another.

  6. #26
    Just Joined!
    Join Date
    May 2011
    Posts
    38
    Just one quick question - would editing this file with visudo have caught the typo he made earlier whereby he locked himself out?
    Well, I don't know exactly what happens when editing the sudoers with another program other than with visudo. However, the only changed line works again. So, I believe that was not a problem.

    If you don't know what you're doing, you're best doing nothing. However, to learn you have to make mistakes, and break things. Fixing your borkage is the best way to learn, and it's always fixable, one way or another.
    I agree with you, we only way to learn is making mistakes and fixing them. The consequences are also measured before doing something. Duplicating the Linux SD card is one solution to avoid future problems.

  7. #27
    Just Joined!
    Join Date
    May 2011
    Posts
    38
    Thanks again for your suggestion, Ak.

    Code:
    SHELL=/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/path.my_script
    I have tried it also but it did not work until now..
    Would it be possible that the script which is started after booting, writes down the password automatically. I have searched for a command line for that but nothing until now.

  8. #28
    Just Joined!
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    29
    OK - since I'm at a complete loss, the next step would be to look at the /var/log/messages and /var/log/auth.log files to see if there's an error being logged there.

    Out of curiosity, do you start your script like this?
    Code:
    bash /path/to/script
    If so, then you need to specify exactly that in the crontab. The other option is to make the script executable:
    Code:
    chmod +x /path/to/script
    Another option is to echo something out from the script into a file in /tmp and have see if the file is created. If it is, then the script is running but most likely not giving you the output you expect.

    Try those couple of things and see if any of them help you get to the root of the problem.

    Cheers,
    ak.

  9. #29
    Just Joined!
    Join Date
    May 2011
    Posts
    38
    Yes, I have done this.
    when ask for the permissions of my script, I get:
    Code:
    -rwxr-xr-x 1 my.username my.username 55 1970-01-01 01:26 test.sh

  10. #30
    Just Joined!
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    29
    Quote Originally Posted by freddyglima View Post
    I have written a small shell script called test.sh:

    Code:
    #!/bin/bash
    ./helloworld
    bash
    After looking back to the first few pages of your script, I realized that you need to be in the correct directory to call your script for it to work as intended. As such, instead of calling your helloworld program as:
    Code:
    ./helloworld
    you should call it using a full path. If you don't want to include the full path (say for portability reasons), then I'd suggest:
    Code:
    #!/bin/bash
    $(dirname $0)/helloworld
    bash
    I'm grappling at straws here so I hope this finally works.

    Cheers,
    ak.

Page 3 of 4 FirstFirst 1 2 3 4 LastLast

Posting Permissions

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