General TC > General TC Talk

Bash script help

(1/2) > >>

MTCAT:
Hi everyone,

I would like to add the functionality/commands contained in test.sh into start_logger_TC.sh

test.sh, when run on its own, after running start_logger_TC.sh, works fine, but when I try to add the commands in test.sh to start_logger_TC.sh (at the end of start_logger_TC.sh, after all the "aterm ...." commands), the taskset commands don't get run properly.

Can I call a script file (test.sh) from within start_logger_TC.sh maybe? But I don't know why the test.sh commands wouldn't work in the start_logger_TC.sh file directly?

I'm trying to force mt_logger to run on one core (and stay there) and mt_adc to run on the other core, it seems to help stability as otherwise the two programs flip-flop between the two cores.

Thanks to your help I've got UDMA/100 going and with the taskset commands entered manually, I've ran the little system for more than 39 hrs with no adc timeout errors!

Just have to get the program to load some temperature readings from "digitemp" program, and maybe differentiate between GPS and Glonass satellites, and the system is ready to go!

Thanks,

David

Rich:
Hi MTCAT
The last line in  start_logger_TC.sh  is:

--- Code: ---aterm -geometry 80x12+120+440 -title "MT Logger" -e sh -c "/home/tc/.local/bin/mt_logger "
--- End code ---


--- Quote from: MTCAT on April 21, 2023, 03:25:26 PM --- ... but when I try to add the commands in test.sh to start_logger_TC.sh (at the end of start_logger_TC.sh, after all the "aterm ...." commands), the taskset commands don't get run properly. ...
--- End quote ---
When you did that did you change the last line to:

--- Code: ---aterm -geometry 80x12+120+440 -title "MT Logger" -e sh -c "/home/tc/.local/bin/mt_logger " &
--- End code ---

Rich:
Hi MTCAT
You should probably also add a sleep command between the
last  aterm  command and the added  taskset  commands.

MTCAT:
Hi Rich,

Thanks for the help, no I did not change the last line of start_logger_TC.sh by adding the ampersand.

When I saw those ampersands in the start_logger_TC.sh script file I thought that it was for running the processes as background? Sorry, thinking about it, it wouldn't make sense to run the GUI as a background process since we wouldn't be able to interact with it?!

I need to add an ampersand to the last line in the original start_logger_TC.sh script in order to get the following taskset commands to run properly?

I was wondering about adding an extra sleep command there as well, thanks.

Thanks,

David

Rich:
Hi MTCAT
A command that provides a surface to draw on will display when launched
in the background. Open a terminal and try the following commands:

--- Code: ---aterm -e top &
editor &
--- End code ---
For the first command  aterm  provides the drawing surface.
For the second command  fltk  creates a window to draw on.


--- Quote from: MTCAT on April 21, 2023, 05:26:31 PM --- ... I need to add an ampersand to the last line in the original start_logger_TC.sh script in order to get the following taskset commands to run properly? ...
--- End quote ---
Yes, you do. Consider the following example:

--- Code: ---#!/bin/sh
Command1
Command2
--- End code ---
Command2  can't run until  Command1  finishes. If you background
Command1  then  Command2  can run before  Command1  finishes.

If you don't add the ampersand, your taskset commands won't run
until the  mt_logger  program finishes running.

Navigation

[0] Message Index

[#] Next page

Go to full version