I'm making a rather big (at least i think so) shell script which includes a host side and a target side. The host being an actual computer running Linux/various distros and the target being a DevKit8000 (almost the same as a beagleboard).
The DevKit8000 runs on kernel version 3.2.6.
But there are a few things which i haven't been able to do so far, so i'm hoping some of you can help me out.
1) I would like to have all the variables that can be changed by the user in 1 file called "settings", so it's easier for the user to edit 1 file instead of multiple files.
I've tried to use 'export' to mark variables, then run the settings.sh script just before running my main script, but the main script can't find the exported variables no matter what i do?
2) Is it possible to change hardcoded variables while inside a script? I have some variables that link to files, and i would like for the user to be able to change the name of the files while inside the script, so he wont have to open the file up in a text editor to manually edit them.
3) I've trapped CTRL+C so it restarts my script instead of exitting it.
Is there any way to simulate the keypress CTRL+C in code?
4) Is there a way to make a script non-executable when done manually by the user, but remain executable when executed from another script?
I have several scripts, and i only want the user to be able to execute the "main" script, while the "main" script can still execute all the sub-scripts.
5) My target-side script involves inserting/removing linux kernel modules, and some of these modules have printk functions in them, with a log level high enough to be printed to the screen.
This doesn't look very good if it prints out messages in the middle of my script. I wish to suppress the messages so they ONLY show up when using 'dmesg' and dont get printed out to the screen.
I was thinking about piping them out to /dev/null, but not sure how about to do it for printk (seeing as it isn't actually inside my script), and would that cause them to not show up in 'dmesg' ?
6) How can i check the return values/error returns for functions?
For example when i use 'ssh user@target' and it can't connect for some reason. How can i check what the error message was and do something based on that info?
I would like to simply echo something to the user if ssh fails and then not continue with the rest of the script.
7) I've used the 'resize' function on my host machine script to resize the terminal window so the entire menu can fit on there. That's fine and it works, but my problem is that on my target, the 'resize' function is non-existant.
So if the target script is called, i can't resize the window, meaning the menu could possibly look distorted and ugly.
Is there any method that works like 'resize', or would it be possible for me to add 'resize' to my target?
8) Same as the above with 'resize', but this one is for '$LINENO'. It is available on my host machine, but not on my target.
Any other command that works like it, or can i add it manually?
9) A picture is worth 1000 words:
I would like to fix it, so if a word is seperated at the end of the terminal window, it just jumps down to the next line.
That way it looks much better.
I know it's a lot of questions in 1 post, but would rather just add them all up here instead of making more posts.
I would love some help, even if it's only with a few of the questions :)