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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

At this moment I have:

#!/bin/bash
screen -p 'ScreenName' -x eval 'stuff '"'"$@"'"'\015'
echo eval 'stuff '"'"$@"'"'\015'

But when I call my script as:

# script.sh asd "asd" 'asd'

my arguments passed as: asd asd asd

and I get output:

eval stuff 'asd asd asd'\015

I except a: asd "asd" 'asd'

How I can change my script to pass whole arguments line with all quotes?

share|improve this question
up vote 5 down vote accepted

Your shell is not passing the quotes through to the script. If you want to pass quotes, escape them with a backslash:

# ./script.sh asd \"asd\" \'asd\'
share|improve this answer
    
It's not what I want, but anyway there are no other solutions (spent whole night searching). – Arthur Halma Sep 3 '12 at 6:50
sh -c "screen -x 'ScreenName' -X eval 'stuff \"$@\"\015'"
share|improve this answer

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.