Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I tried to use in a bash script, the unix command script (to log all input/ouput from the shell)
#!/bin/bash
script toto.txt
ls
exit
The script command is executed but nothing happend after unless 'exit' is typed to stop the script command then ls is executed.
The unix command script seems to open a second bash shell (pts/2) where I guess the ls command has to be executed but I didn't have found a way to do it???
If the only thing you need "toto.txt" to contain is the output from the "ls" command, then you could just pipe the output from "ls" to a file.
Else you could tell us why you need the "ls" command line to be there as well.
I used ls as an example in fact I am writing a script to perform regression testing of software build that happend each week.
Instead of running all the test by hand I wrote a script (that call each test case around 20) and I want to log what happend to be able to verify if any test failed (each testcase execution takes around 5 mn).
I just don't think using "script" is the right way, it's sposed to be an interactive tool. Why not "set -x" and pipe the output to a log, verify a test failed using exit status and on that basis parse logs?
Ridiculous example (but that's my approach):
logf="${__tmpdir}/$1.log"
parseLog() { grep "${logf}" <something>; do somethingElse; }
parseExit() { case $1 in 0) printf "%sOK\n";;
*) printf "%sFAILED\n"; parseLog;; esac; }
activate() { printf "%sActivating $1 "; set -x; $1 2>&1 "${logf}";
parseExit $?; set +x; }
for i in $(seq 0 2); do activate testcase${i}; done
# testcase? need to be functions within this script or sourced
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.