Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1550  / 1 Year ago, sun, april 23, 2023, 8:15:33

I have successfully run command



screen -S Run -X stuff 'stop'`echo -ne '015'` 


in the terminal and had screen Run receive the stop command and then receive the simulated enter press. This results in the program running in that screen terminating. However when I try to make a script which looks like this



#!/bin/sh
screen -S Run -X stuff 'stop'`echo -ne '015'`


the screen revives the text



-X: stuff: invalid option stop-ne


I would like to know what is wrong with my script and how to correct it so screen Run receives the stop command and then receives an enter press


More From » scripts

 Answers
0

The sh version of echo does not support options.



Change your script to be run with Bash like so:





#!/bin/bash
screen -S Run -X stuff 'stop'"$(echo -ne '015')"


Alternatively, just put a literal newline in the string instead of relying on echo:



#!/bin/sh
screen -S Run -X stuff 'stop
'

[#27514] Sunday, April 23, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fertion

Total Points: 436
Total Questions: 121
Total Answers: 156

Location: England
Member since Sun, May 21, 2023
1 Year ago
;