3

I am trying to write the time in a screen in shell script, however, I am extremely inexperienced with the screen command. Thus, apologies for my mistakes. I have a transmitter that operates in a screen created by the shell script I wrote, as follows:

screen -S trans -L /dev/ttyACM0
screen -S trans -X stuff 's'$(echo -ne '\015')
sleep 8s
screen -S trans -X quit

I am not quite sure what the second line is echoing. Nevertheless, this code produces a screenlog.0 file at the end of the process, and my goal is to write the time ($(date)) at the end of this file. Thank you.

  • With echo 'stuff' >> File you can add something to the end of a file. Btw this script is rather advanced, did you write it yourself? – ADDB May 31 '17 at 18:56
  • most of it, yes :) – Ptheguy May 31 '17 at 19:21
  • 1
    $(echo -ne '\015') will be a CR / carriage return character, the enter without the newline (that is hex 10) the character with hex code 13 (octal code 15). -n is no newline, -e to interpret backslash character (\n,\015...). you're sending the command stuff 's'CR – mazs May 31 '17 at 19:58
3

Sounds simple enough, let me know if I missed something.

At the end of that script, last line put:

date >> screenlog.0

entire script:

screen -S trans -L /dev/ttyACM0
screen -S trans -X stuff 's'$(echo -ne '\015')
sleep 8s
screen -S trans -X quit
date >> screenlog.0
  • just date, and no "$(date)"? – Ptheguy May 31 '17 at 19:10
  • @Ptheguy Good times! up-vote my answer if you think it helped. :) – AfroJoe May 31 '17 at 19:19
  • Man, I don't have enough reputations to up vote, sorry – Ptheguy May 31 '17 at 19:21
  • You can vote anyway, it just won't be displayed in the count – ADDB May 31 '17 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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