Question regarding quotation syntax


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Question regarding quotation syntax
# 1  
Old 09-15-2014
Error Question regarding quotation syntax

Hey guys, my first post on UNIX Forums(much overdue IMO)!

I've got this bit of code that doesn't seem to be working correctly for an Android app I'm working on:

Code:
"screen -S gmod1 -p 0 -X stuff " & "" & command.text & "`echo -ne '\015'`"""

Basically it types command.text(variable determined in Android app) into a screen session and hits ENTER. It works perfectly fine if its only one word, but if I want to do two words, I must manually put them in quotations in the actual app. Is there any way for me to wrap command.text in quotations programmatically?


Just out of curiosity I tried adding another
Code:
& "" &

around command.text but it didn't change anything.


Any help would be greatly appreciated as I'm almost done the app and don't want to get stuck on a syntax issue.

Thanks! Smilie
# 2  
Old 09-15-2014
Did you try to use escaped quotes (\")?
# 3  
Old 09-15-2014
like this?

Code:
"screen -S gmod1 -p 0 -X stuff " & "" & \"command.text\" & "" & "`echo -ne '\015'`"""

I should also mention, the UNIX part of this is instead of typing the text and hitting enter its saying "-X: stuff: invalid option 'say' " (because in this case command.text is "say hi")


Escape quotes aren't supported in this language. I'm writing to their forums as well.

Last edited by stingwraith; 09-15-2014 at 04:22 AM..
# 4  
Old 09-15-2014
This is how I send commands to a screen session with -X stuff:

Code:
screen -p 0 -S gmod1 -X stuff "$(printf "%s\r" "say SERVER BACKUP STARTING. Please logoff ASAP...")"

I don't know how this would be defined in your app, perhaps:

Code:
"screen -p 0 -S gmod1 -X stuff "$(printf "%s\r" "command.text")""

Or perhaps this:

Code:
"screen -p 0 -S gmod1 -X stuff  'command.text'" & "`echo -ne '\015'`"


Last edited by Chubler_XL; 09-15-2014 at 05:50 PM..
# 5  
Old 09-15-2014
Other forum answered finally! The proper syntax was

command.text = """" & command.text & """".


Now I'm stuck on trying to print the output from the screen session, any pointers?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A Perl Syntax Question.

Greetings! Here's what I believe is a "simple one" for the community tonight ;) What I'm trying to do is assign a "true/false" value to a variable depending upon whether a named process (some-process) exists; and then test for this value in the succeeding logic. I banged my head against the... (2 Replies)
Discussion started by: LinQ
2 Replies

2. Programming

Perl syntax question

Hallo everybody, I have a following problem - I'm doing a map funciont to fill in a HTML table and I want to use some radiobutton groups. Unfortunatelly, they are grouped by names, so I have to add some "counter" that will divide one row from another, and I'm using CGI.pm for generating the... (3 Replies)
Discussion started by: duskos
3 Replies

3. Shell Programming and Scripting

Question about syntax error

first of all.. sorry about all the question bombing.. im bored atm so im currently playing around with sh scripting hehe s = `expr ls -s Documents | grep Music | awk '{ print $1 }' ` t = `expr $t + $s` it give syntax error s not found t not found lol... any idea why? (7 Replies)
Discussion started by: Nick1097
7 Replies

4. Shell Programming and Scripting

tar -C syntax question

I am writing a perl script to tar multiple files (in unix) from a given directory to a given output directory. I do NOT want the file path included in the tar, so I've flagged the -C option. Example: tar -cvf tar/1.tar -C htmp/source/ 1-1-1.xml However, I need to do this for a number of target... (3 Replies)
Discussion started by: michanjohns
3 Replies

5. UNIX for Advanced & Expert Users

SNMP syntax question

Hello, I need to create an snmp.comf file that defines 2 IPs to the same community string. Do I need to have 2 community strings with the same name and diff't IPs? Or should I have 1 string and list the IPs? (comma seperated?) Example: rocommunity EC_8000_RO arguments EC_8000_RO... (2 Replies)
Discussion started by: felbvts
2 Replies

6. Shell Programming and Scripting

awk syntax question

Hi I use awk command to delete the first blanc line of a file: awk '/^$/ && !f{f=1;next}1' infile > outfile can somebody please explain me what the last "1'" in !f{f=1;next}1' stands for... Thansk a lot -A (3 Replies)
Discussion started by: aoussenko
3 Replies

7. UNIX for Dummies Questions & Answers

Piping syntax question

There are are lots of examples of piping output FROM the 'ls' command TO another command, but how does one pipe output TO the 'ls -l' command? For example, use 'which' to find a file, then use 'ls -l' to view the permissions, groups, etc. in a single step: which <filename> | ls -l returns... (4 Replies)
Discussion started by: johne1
4 Replies

8. UNIX for Dummies Questions & Answers

AWK syntax question

Hi, Have to check file names in some given directory. SO, What is the right syntax here: *$3*=="'$object_list'" - just wanted to check if $3 is in the object_list. And also, Do I need so many quotes around? (5 Replies)
Discussion started by: Leo_NN
5 Replies

9. UNIX for Dummies Questions & Answers

Tricky Quotation Question

Hi, I am at a point in my script where I defined the number of the command line parameter I would like to set a variable equal to: parameter_number=14 I would then like to set a variable equal to the correct parameter: variable=$parameter_number The issue here is that {} is required... (2 Replies)
Discussion started by: msb65
2 Replies

10. Shell Programming and Scripting

awk syntax question

Hi there could someone explain what is happening in the following function/statement for me, im just a little confused code = 'BEGIN{FS=","} { printf ("%-11s,%s%s%s,%07.2f,%14s,%-3s\n",$1,substr($2,9,2),substr($2,6,2),substr($ 2,3,2),$9,$10,$12) } this function is called later in the... (2 Replies)
Discussion started by: hcclnoodles
2 Replies
Login or Register to Ask a Question