1

demo.sh has following line:

. ./one.sh  > ../Results/myResult.txt 2>&1

when i run ./demo.sh it is giving:

ambiguous redirectine 1: 1

But the myResult.txt gets created at appropriate location with size 0 KB.

If i remove the redirection of output, it script works fine. What is wrong with my script? I have gone through Ambiguous output redirect on solaris, shell script ambiguous redirect, ambiguous redirect - file gets created. Nothing helped though.

4
  • I've tried a similar command, and it works. What shell are you using? Commented Aug 8, 2013 at 17:36
  • I tried it without putting shebang. When I put shebang it is saying : No such file or directory. I tried it with sh, ksh, bash. Commented Aug 8, 2013 at 17:37
  • What are you putting after the shebang? What's your system default shell? Commented Aug 8, 2013 at 17:38
  • I don't know what shell was default. I tried changing the shell by typing bash,sh. "ps -p $$" shows accrodingly. My shebang is "#!/bin/sh". I change it when i change the shell. Commented Aug 8, 2013 at 17:42

1 Answer 1

1

If you're saving your script with DOS-style line endings (CRLF instead of LF), that can produce all of the symptoms you're seeing.

Change the line endings using the text editor or command-line utility of your choice, then try again.

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

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.