0

I have a little bash script to run, but it appears to stop without errors on the second line:

export REQUIRE_TRIGGER=0
sudo -s -H
killall ptpd ntpd
nice -n -19 ptpd -gGW -b eth0 -s2 -i NTP -t -c D 

The script is in a file. What am I missing?

8
  • 1
    You're missing that killall won't be run until sudo finishes and exits. Commented Jul 18, 2017 at 20:15
  • The script is inside a file. Commented Jul 18, 2017 at 20:21
  • Yes, you included the commands you want sudo to run in the file, but you didn't do anything to cause them to be fed to stdin of the shell sudo starts. So that shell is still trying to read from the script's original stdin, not reading the commands later in the script. Commented Jul 18, 2017 at 20:22
  • ...which is to say: bash somescript is not at all the same thing as bash <somescript. (Not that the latter is safe either: The shell is perfectly free to consume lines ahead of the one it's currently executing, and in many cases is required to do so, making that file content unavailable to other programs inheriting the FD). Commented Jul 18, 2017 at 20:25
  • (Adding the fact that "the script is in a file" to your question does not make this any less duplicative; the other answers still apply just as much as they did pre-edit). Commented Jul 18, 2017 at 20:26

1 Answer 1

1

try to do

    sudo killall ptpd ntpd
    sudo nice -n -19 ptpd -gGW -b eth0 -s2 -i NTP -t -c D 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.