[SOLVED] SMILEYNET Standard Scripts: Debugging Linux Versions
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
SMILEYNET Standard Scripts: Debugging Linux Versions
I am trying to debug the Linux version of my standard scripts. My standard scripts are a "network platform", that I can rely on. As soon as I can, the general rule is on certain parts of the network, no standard scripts, no admittance. This limits it to certain OSs, which I pre-approve. Linux is the first OS, with the distribution being Linux Mint, that I want to re-enable the feature on.
I DID have the Linux version working. However, I lost most of my code. So now I don't have all code working. But I have a great start! This will be used first of all mainly on my network. Once I get this, I can move on to more stuff for my network. I would like to focus on Linux Mint first this time. Windows is changing and requiring too much money to keep up with right now.
We'll therefore focus on that. I'm also focusing on making sure what I've already written works. It does NOT so far. I might later share the whole thing, so others can benefit from my work and whoever helps me. But this particular program in this state, is NOT my goal to sell or anything. OK. Here goes!
#! /bin/bash
if [ $# -eq 0 ]; then
echo Usage: cnassoftwarefolders.sh {path}
echo
else
pushd . > /dev/null
cd $1
echo Making Standard Directories for Software...
echo DOCUMENTATION
mkdir DOCUMENTATION
echo BOOTLOADERS
mkdir BOOTLOADERS
echo OPERATING_SYSTEMS
mkdir OPERATING_SYSTEMS
echo DRIVERS
mkdir DRIVERS
echo PATCHES
mkdir PATCHES
echo PROGRAMS
mkdir PROGRAMS
echo CONFIGURATION_FILES
mkdir CONFIGURATION_FILES
echo BACKUP
mkdir BACKUP
echo CUSTOM
mkdir CUSTOM
echo Making Directories for Operating Systems...
cd BOOTLOADERS
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
cd OPERATING_SYSTEMS
pushd . > /dev/null
. mknastypes2.sh
popd
cd ..
cd DRIVERS
pushd . > /dev/null
. mknasosnames.sh
popd
cd ..
cd PATCHES
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
cd PROGRAMS
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
cd CONFIGURATION_FILES
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
cd BACKUP
cd ..
cd CUSTOM
mkdir READY
cd READY
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
mkdir NOT_READY
cd NOT_READY
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
cd ..
echo Done!
popd > /dev/null
fi
mknasosnames.sh:
Code:
#! /bin/bash
pushd . > /dev/null
echo Making directories for each operating system...
while read -a line
do
echo Creating ${line[0]}...
if [ -d ${line[0]} ]; then
echo There\'s already a directory named ${line[0]}
else
mkdir ${line[0]}
fi
cd ${line[0]}
while read -a line2
do
mkdir ALL
if [ -d ${line2[0]} ]; then
echo There\'s already a directory names ${line2[0]}
else
mkdir ${line2[0]}
cd ${line2[0]}
if [ ${line2[1]} == "(none)" ]; then
pushd . > /dev/null
. mknastypes2.sh
popd > /dev/null
cd ..
else
pushd . > /dev/null
. mknastypes.sh ${line2[1]}
popd > /dev/null
cd ..
fi
fi
done < ${line[1]}
cd ..
done < /etc/settings/Operating_Systems/osnames.sdr
popd > /dev/null
mknastypes.sh:
Code:
#! /bin/bash
pushd . > /dev/null
echo Making directories for each operating system...
while read -a line
do
echo Creating ${line[0]}...
if [ -d ${line[0]} ]; then
echo There\'s already a directory named ${line[0]}
else
mkdir ${line[0]}
fi
cd ${line[0]}
while read -a line2
do
mkdir ALL
if [ -d ${line2[0]} ]; then
echo There\'s already a directory names ${line2[0]}
else
mkdir ${line2[0]}
cd ${line2[0]}
if [ ${line2[1]} == "(none)" ]; then
pushd . > /dev/null
. mknastypes2.sh
popd > /dev/null
cd ..
else
pushd . > /dev/null
. mknastypes.sh ${line2[1]}
popd > /dev/null
cd ..
fi
fi
done < ${line[1]}
cd ..
done < $1
popd > /dev/null
mknastypes2.sh:
Code:
#! /bin/bash
echo Making directories for types of software...
mkdir STANDARD
mkdir OPTIONAL
cd STANDARD
mkdir NORMAL
mkdir SHAREWARE
cd ..
cd OPTIONAL
mkdir NORMAL
mkdir SHAREWARE
cd ..
Last edited by des_a; 11-17-2023 at 09:48 PM.
Reason: Bad code tags
Let's start there, please. Fixing that, will fix a lot. I just don't see what I got wrong when looking at it's code. I've been looking at it for about 3 months so far. I also had to generate the settings from scratch again, so maybe that's the problem.
P.S. - Here's the ones that have been found to work so far. The ones with the 'x', have been known to work now.
Code:
cbackupdrive2.sh x
cbackupdrive.sh x
cdatafolders.sh x
cjbackupdrive.sh x
cnasbackupdrive.sh x
cnasbmediafolders.sh x
cnasdatafolders.sh x
cnaspersonalfolders.sh
cnassoftwaredocsfolders.sh
cnassoftwarefolders.sh
csoftwarefolders.sh
dbackupdrive2.sh x
dbackupdrive.sh x
ddatafolders.sh x
djbackupdrive.sh x
dnasbackupdrive.sh x
dnasbmediafolders.sh x
dnasdatafolders.sh x
dnaspersonalfolders.sh
dnassoftwaredocsfolders.sh
dnassoftwarefolders.sh
dsoftwarefolders.sh
list_commands.sh
mkchosts2.sh
mkchosts.sh
mkdostypes.sh
mkextdrhosts.sh
mkhostdirs2.sh
mkhostdirs.sh
mklinuxtypes.sh
mknames2.sh
mknames.sh
mknasdostypes.sh
mknashosts.sh
mknaslinuxtypes.sh
mknasosnames2.sh
mknasosnames3.sh
mknasosnames.sh
mknastypes2.sh
mknastypes3.sh
mknastypes.sh
mknasversions2.sh
mknasversions.sh
mknaswindowstypes.sh
mkohosts.sh
mkosnames2.sh
mkosnames3.sh
mkosnames.sh
mkrhosts.sh
mktypes.sh
mkversions.sh
mkwindowstypes.sh
shelp.sh
umkhostdirs.sh
uninstall-standard_scripts.sh
mkaphosts.sh
It looks like I figured out this part. I'll see if I figure out everything or not. This is the solution to this part:
cnassoftwarefolders.sh:
Code:
#! /bin/bash
if [ $# -eq 0 ]; then
echo Usage: cnassoftwarefolders.sh {path}
echo
else
pushd . > /dev/null
cd $1
echo Making Standard Directories for Software...
echo DOCUMENTATION
mkdir DOCUMENTATION
echo BOOTLOADERS
mkdir BOOTLOADERS
echo OPERATING_SYSTEMS
mkdir OPERATING_SYSTEMS
echo DRIVERS
mkdir DRIVERS
echo PATCHES
mkdir PATCHES
echo PROGRAMS
mkdir PROGRAMS
echo CONFIGURATION_FILES
mkdir CONFIGURATION_FILES
echo BACKUP
mkdir BACKUP
echo CUSTOM
mkdir CUSTOM
echo Making Directories for Operating Systems...
cd BOOTLOADERS
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
cd OPERATING_SYSTEMS
pushd . > /dev/null
. mknastypes2.sh
popd
cd ..
cd DRIVERS
pushd . > /dev/null
. mknasosnames.sh
popd
cd ..
cd PATCHES
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
cd PROGRAMS
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
cd CONFIGURATION_FILES
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
cd BACKUP
cd ..
cd CUSTOM
mkdir READY
cd READY
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
mkdir NOT_READY
cd NOT_READY
pushd . > /dev/null
. mknasosnames.sh
popd > /dev/null
cd ..
cd ..
echo Done!
popd > /dev/null
fi
mknasosnames.sh:
Code:
#! /bin/bash
pushd . > /dev/null
echo Making directories for each operating system...
while read -a line
do
echo Creating ${line[0]}...
if [ -d ${line[0]} ]; then
echo There\'s already a directory named ${line[0]}
else
mkdir ${line[0]}
fi
cd ${line[0]}
while read -a line2
do
#mkdir ALL
if [ -d ${line2[0]} ]; then
echo There\'s already a directory names ${line2[0]}
else
mkdir ${line2[0]}
cd ${line2[0]}
if [ ${line2[1]} == "(none)" ]; then
pushd . > /dev/null
. mknastypes2.sh
popd > /dev/null
cd ..
else
pushd . > /dev/null
. mknastypes.sh ${line2[1]}
popd > /dev/null
cd ..
fi
fi
done < ${line[1]}
cd ..
done < /etc/settings/Operating_Systems/osnames.sdr
popd > /dev/null
mknastypes.sh:
Code:
#! /bin/bash
pushd . > /dev/null
echo Making directories for each operating system...
while read -a line
do
echo Creating ${line[0]}...
if [ -d ${line[0]} ]; then
echo There\'s already a directory named ${line[0]}
else
mkdir ${line[0]}
fi
cd ${line[0]}
while read -a line2
do
#mkdir ALL
if [ -d ${line2[0]} ]; then
echo There\'s already a directory names ${line2[0]}
else
mkdir ${line2[0]}
cd ${line2[0]}
if [ ${line2[1]} == "(none)" ]; then
pushd . > /dev/null
. mknastypes2.sh
popd > /dev/null
cd ..
else
pushd . > /dev/null
. mknastypes.sh ${line2[1]}
popd > /dev/null
cd ..
fi
fi
done < ${line[1]}
cd ..
done < $1
popd > /dev/null
mknastypes2.sh:
Code:
#! /bin/bash
echo Making directories for types of software...
mkdir STANDARD
mkdir OPTIONAL
cd STANDARD
mkdir NORMAL
mkdir SHAREWARE
cd ..
cd OPTIONAL
mkdir NORMAL
mkdir SHAREWARE
cd ..
Also, I had my test configuration wrong. I must always specify the whole path, and then, when I'm done, I end it by putting (none) in the path, like this:
osnames.sdr:
Code:
Windows /etc/settings/Operating_Systems/Windows/Windows.sdr
Windows/Windows.sdr
Code:
XP (none)
10 (none)
It had been a LONG time wince I'd needed to write the configuration for this set of programs. Even what I had before I lost it was way! way! out of date!
Finding and using some old code, I was able to complete the one I was working on, by also making a few tweaks. Here is the modified files:
mkosnames.sh
Code:
#! /bin/bash
pushd . > /dev/null
echo Making directories for each operating system...
#while read -a line
#do
# echo Creating ${line[0]}...
# if [ -d ${line[0]} ]; then
# echo There\'s already a directory named ${line[0]}
# else
# mkdir ${line[0]}
# fi
#
# cd ${line[0]}
#
# while read -a line2
# do
#
# #mkdir ALL
#
# if [ -d ${line2[0]} ]; then
# echo There\'s already a directory names ${line2[0]}
# else
# mkdir ${line2[0]}
#
# cd ${line2[0]}
#
# if [ ${line2[1]} == "(none)" ]; then
# pushd . > /dev/null
# . mknastypes2.sh
# popd > /dev/null
# cd ..
# else
# pushd . > /dev/null
# . mknastypes.sh ${line2[1]}
# popd > /dev/null
#
# cd ..
# fi
# fi
# done < ${line[1]}
#
# cd ..
#done < /etc/settings/Operating_Systems/osnames.sdr
while read -a line
do
echo Creating ${line[0]}...
if [ -d ${line[0]} ]; then
echo There\'s already a directory named ${line[0]}
else
mkdir ${line[0]}
fi
cd ${line[0]}
if [ ${line[1]} == "(none)" ]; then
pushd . > /dev/null
. mknastypes2.sh
popd > /dev/null
cd ..
else
pushd . > /dev/null
. mknastypes.sh ${line[1]}
popd > /dev/null
cd ..
fi
done < /etc/settings/Operating_Systems/osnames.sdr
popd > /dev/null
mknasostypes.sh
Code:
#! /bin/bash
pushd . > /dev/null
echo Making directories for each operating system...
#echo Making All directory...
#mkdir ALL
#cd ALL
#mkdir STANDARD
#mkdir OPTIONAL
#cd STANDARD
#mkdir NORMAL
#mkdir SHAREWARE
#cd ..
#cd OPTIONAL
#mkdir NORMAL
#mkdir SHAREWARE
#cd ..
#cd ..
#while read -a line
#do
# echo Creating ${line[0]}...
# if [ -d ${line[0]} ]; then
# echo There\'s already a directory named ${line[0]}
# else
# mkdir ${line[0]}
# fi
#
# cd ${line[0]}
#
# while read -a line2
# do
#
# #mkdir ALL
#
# if [ -d ${line2[0]} ]; then
# echo There\'s already a directory names ${line2[0]}
# else
# mkdir ${line2[0]}
#
# cd ${line2[0]}
#
# if [ ${line2[1]} == "(none)" ]; then
# pushd . > /dev/null
# cd $(line[0])
# . mknastypes2.sh
# popd > /dev/null
# cd ..
# else
# pushd . > /dev/null
# . mknastypes.sh ${line2[1]}
# popd > /dev/null
#
# cd ..
# fi
# fi
# done < ${line[1]}
#
# cd ..
#done < $1
#while read -a line
#do
# echo Creating ${line[0]}...
# if [ -d ${line[0]} ]; then
# echo There\'s already a directory named ${line[0]}
# else
# mkdir ${line[0]}
#
# cd ${line[0]}
#
# while read -a line2
# do
#
# #mkdir ALL
#
# if [ -d ${line2[0]} ]; then
# echo There\'s already a directory names ${line2[0]}
# else
# mkdir ${line2[0]}
#
# cd ${line2[0]}
#
# . mknastypes2.sH
#
# cd ..
# fi
# done < ${line[0]}
#
# cd ..
# fi
#done < $1
while read -a line
do
echo Creating ${line[0]}...
if [ -d ${line[0]} ]; then
echo There\'s already a directory named ${line[0]}
else
mkdir ${line[0]}
fi
cd ${line[0]}
if [ ${line[1]} == "(none)" ]; then
pushd . > /dev/null
. mknastypes2.sh
popd > /dev/null
cd ..
else
pushd . > /dev/null
. mknastypes.sh ${line[1]}
popd > /dev/null
cd ..
fi
done < $1
popd > /dev/null
Now everything on the list that's supposed to work, does, EXCEPT for shelp.sh. I'll take another look at it tommorrow. I don't know whether I'm stuck for now on it or not. I had NO earlier versions, except maybe in very recent stuff, which I lost. I had it working, but I lost it. I don't know how I lost the file, but I did. When I get this much complete, I will move onto the next step of making sure that's all the standard scripts I need for now. If it is NOT all, I will have to start writing them from scratch.
So now, shelp works. Everything on the list works now. I thought shelp was working before, and I think it was. However, appearently, an update broke my script shelp.sh. I'd had the custom help section triggered by the character '?', and now, that doesn't work. So I made it triggered by '-', instead. I know on the shell, '?', is a wildcard, but for that command, I didn't want to use it so. I like my changes, so I'll keep it. But does anybody know whether there was a way to keep it? I don't know if anybody knows or not. If that question can be answered great! If not, no big deal. The priority is to get my standard scripts working.
I have everything now working, but I have just a few more specifications for the standard scripts. As I need help, I will ask for it here. I think that's the extent to which the old code will be capable of being used. It came from servers which I haven't took down yet. I'd had some older versions of them, to use. I didn't have it organized on my NAS, so I had to pull it from actual production, IE; /bin on that system, and retype it into the NAS production.
I'd had the custom help section triggered by the character '?', and now, that doesn't work. So I made it triggered by '-', instead. I know on the shell, '?', is a wildcard, but for that command, I didn't want to use it so. I like my changes, so I'll keep it. But does anybody know whether there was a way to keep it? I don't know if anybody knows or not. If that question can be answered great! If not, no big deal. The priority is to get my standard scripts working.
You can disable expansion of the ? (and other globbing options) using the -f option, but how it works may depend on how your script is invoked. For example, if your script is invoked by another for which globbing characters have already been expanded it is too late! And obviously, if your script depends on globbing for its operation then it may break in other ways.
But any of these should work within the script itself for the simple case:
Code:
Add option to the shebang line...
#!/bin/bash -f
Use set at top of script...
set -f
or
set -o noglob
You may also disable globbing from the parent shell by invoking shelp.sh like this:
Code:
set -f; ./shelp.sh ?
See man bash and experiment based on your exact use case.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.