Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I execute the command screen -S myscreen -X stuff $'search add $1 \015' from a shell it works perfectly. If I put it in a .sh file and run it as sh /test.sh variablehere it sends it to screen as $'search add variablehere'.

Why would it normally work but not from sh? Im on Ubuntu Server if it matters.

share|improve this question
    
Found a solution, still not sure why it refused to work. unix.stackexchange.com/questions/5847/… –  nosedive25 Aug 21 '11 at 23:21
    
Could you post this as an answer? So that you can accept it when possible and "close" the question. –  MaxMackie Aug 22 '11 at 0:12
    
The problem in the other question appears to be different to me. If it "solved" your problem it's only because it sidestepped your issue, which seems to be that bash != sh. You can't do fancy stuff in bash and exect it to work the same in a different shell, but you can build and run scripts with bash so it should be an easy fix. –  Caleb Aug 22 '11 at 8:09
    
@MaxMackie, I did but it added it as a comment. No need to now as enzotib provided a good explanation of not only how to fix the issue but why it happened. –  nosedive25 Aug 23 '11 at 2:22
add comment

1 Answer

up vote 2 down vote accepted

The expression $'search add $1 \015', and in general the quoting $'string' is a bash features (probably also of other shells), so it works from command line, where you probably are using bash.

It for sure do not work for sh, that in ubuntu points to dash.

So the simple solution is to invoke your script with bash ./test.sh.

share|improve this answer
    
Apparently it points to dash because running it with bash worked just fine. Thanks. –  nosedive25 Aug 23 '11 at 2:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.