1

I'm trying to write a script that contains this

screen -S demo -d -m which should start a new screen session named demo and detach it. Putting screen -S demo -d -m in the command line works.

If I put it in a file named boot.sh, and run it ./boot.sh I get

Error: Unknown option m Why does this work in the command line but not as a shell script?

10
  • What happens if you do: . ./boot.sh? Commented May 20, 2011 at 2:08
  • 4
    Could you exhibit a complete script that fails. If the one you are actually using is more than a few lines long, prepare a minimal version. Commented May 20, 2011 at 2:25
  • @dmckee What I have above is the entire script, its just the one screen command Commented May 20, 2011 at 2:48
  • 1
    FWIW, I can't reproduce with the information you've given. "screen -S demo -d -m" behaves the same either on the command line or as the sole line in an executable script (without a shebang line). (Ubuntu 10.04, screen 4.00.03jw4 (FAU) 2-May-06) Commented May 20, 2011 at 3:00
  • 2
    Just a guess here, but make sure there are no Ctrl-M chars at the end of your command-script by doing cat -vet myScreenLaucher.sh. It you see ^M at the end of the line, you are saving file in Windows file mode. You'll have to find the option in your editor to use Unix line endings. Good luck. Commented May 20, 2011 at 19:44

3 Answers 3

3

This file was transferred from windows and had ctrl-M characters.

Sign up to request clarification or add additional context in comments.

Comments

1

Running "screen" on my Linux machine, a bad option (Screen version 4.00.03jw4 (FAU) 2-May-06) gives the error,

Error: Unknown option -z"

while your description includes no dash before the offending option. I'd check that the characters in your script file are what you expect them to be. There are many characters that look like a dash but which are not.

cat -v boot.sh

may show something interesting as it'll show codes for non-ascii characters.

Comments

0

This may seem a little like the "make sure your printer is plugged in" kind of help, but anyway:

have you tried to check if the screen you're invoking from the script is the same as the one invoked from the command line ?

I'm thinking you may change the PATH variable inside your script somewhere and perhaps screen from the script would be something else (a different version, perhaps ?).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.