Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2nd run exits immediately #3

Open
macie opened this issue Jun 25, 2023 · 3 comments
Open

2nd run exits immediately #3

macie opened this issue Jun 25, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@macie
Copy link
Contributor

macie commented Jun 25, 2023

When I run termrec second time, new shell exits immediately and it is impossible to record any commands:

$ SHELL='/bin/sh' ./termrec rec test.log
CWD: /home/macie/termrec
$ echo 123
123
$ ^D
Session Recorded Successfully!
$ cat test.log
{
	"duration": 5.55092907,
                                          	"version": 1,
	"timestamp": 1687726492,
	"width": 80,
	"height": 30,
	"command": "",
	"title": "",
	"env": {"SHELL":"/bin/sh","TERM":"xterm-256color","PS1":"$(__update_ps1)","PS2":" > "},
	"stdout": [
		[ 0, "" ],
		[ 0.0000, "$ " ],
		[ 2.0180, "e" ],
		[ 0.1563, "c" ],
		[ 0.1489, "h" ],
		[ 0.1277, "o" ],
		[ 0.1662, " " ],
		[ 0.3606, "1" ],
		[ 0.1419, "2" ],
		[ 0.2694, "3" ],
		[ 0.4154, "\u000d\u000d\u000a" ],
		[ 0.0002, "123\u000d\u000a" ],
		[ 0.0396, "$ " ],
		[ 1.7066, "^D\u000d\u000d\u000a" ]
	]
}
$ SHELL='/bin/sh' ./termrec rec test.log
CWD: /home/macie/termrec
Session Recorded Successfully!
$ cat test.log
{
	"duration": 0,
                                                   	"version": 1,
	"timestamp": 1687726530,
	"width": 80,
	"height": 30,
	"command": "",
	"title": "",
	"env": {"SHELL":"/bin/sh","TERM":"xterm-256color","PS1":"$(__update_ps1)","PS2":" > "},
	"stdout": [
		[ 0, "" ]
	]
}

If the program can read commands to be recorded, then it will be easy to automate regression testing during CI job (and local development). Example of simple end-user test where commands are read from stdin, line-by-line:

$ ./termrec rec test_rec.cast <<EOF
echo "test_string"
exit
EOF
$ grep -q "test_string" test_rec.cast
@pegvin
Copy link
Owner

pegvin commented Jun 26, 2023

i don't want to complicate this program to add those features, and i don't think it's a really good idea to allow a "recording" software to execute commands, security wise.

i still don't know what is causing the issue that the program is failing to record second time, i am looking into it.

@macie
Copy link
Contributor Author

macie commented Jun 27, 2023

I share your point of view on features. But this kind of automatic test could help figuring out source of problems - if test passes on all CI, but not on user device, then there is probably something with user-specific configuration.

I've found that all known (to me) terminal recorders allows to specify command to be executed inside recorded session:

  • script -c 'echo "test_string"' test_rec.cast (source)
  • ttyrec -e 'echo "test_string"' test_rec.cast (source)
  • asciinema rec -e 'echo "test_string"' test_rec.cast (source)
    Commands are specified by flag, because input from stdin can never end (for example yes | grep "n").

From my understanding of security there is no difference between writing recorder -c command and recorder then command.

@pegvin
Copy link
Owner

pegvin commented Feb 24, 2024

Hi There, It's been almost a year? I've learnt more about C & Makefiles, and I will implement this feature.

@pegvin pegvin added the enhancement New feature or request label Feb 24, 2024
@pegvin pegvin self-assigned this Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants