LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-17-2023, 09:41 PM   #1
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423
Blog Entries: 43

Rep: Reputation: 36
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!
 
Old 11-17-2023, 09:46 PM   #2
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
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 ..

Last edited by des_a; 11-17-2023 at 09:48 PM. Reason: Bad code tags
 
Old 11-17-2023, 09:50 PM   #3
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
Here is part of my /etc/settings folder.
Attached Files
File Type: txt Operating_Systems.zip.txt (6.0 KB, 4 views)
 
Old 11-17-2023, 09:52 PM   #4
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
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.
 
Old 11-17-2023, 09:54 PM   #5
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
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
 
Old 11-18-2023, 08:25 PM   #6
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
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 ..
 
Old 11-18-2023, 08:29 PM   #7
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
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!
 
Old 11-18-2023, 08:30 PM   #8
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
Now I'll configure it properly and move on to the next tests. I might have tweaked another file, so I'll first see if it still works all the way.
 
Old 11-19-2023, 09:50 PM   #9
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
OK. Doesn't work with the better configuration:

Linux.sdr:
Code:
All (none)
Mandriva /etc/settings/Operating_Systems/Linux/Mandriva/Mandriva.sdr
Mageia /etc/settings/Operating_Systems/Linux/Mageia/Mageia.sdr
Linux_Mint /etc/settings/Operating_Systems/Linux/Linux_Mint/Linux_Mint.sdr
Mandriva/Mandriva.sdr:
Code:
All (none)
2010.1 (none)
Mageia/Mageia.sdr:
Code:
All (none)
8 (none)
Linux_Mint/Linux_Mint.sdr:
Code:
All (none)
20 (none)
21 (none)
21.1 (none)
21.2 (none)
 
Old 11-28-2023, 09:49 PM   #10
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
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
 
Old 11-28-2023, 09:52 PM   #11
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
osnames.sdr
Code:
ALL (none)
Android (none)
IOS (none)
Windows /etc/settings/Operating_Systems/Windows/Windows.sdr
Linux /etc/settings/Operating_Systems/Linux/Linux.sdr
Windows.sdr
Code:
ALL (none)
XP (none)
10 (none)
Linux.sdr
Code:
ALL (none)
Mandriva /etc/settings/Operating_Systems/Linux/Mandriva/Mandriva.sdr
Mageia /etc/settings/Operating_Systems/Linux/Mageia/Mageia.sdr
Linux_Mint /etc/settings/Operating_Systems/Linux/Linux_Mint/Linux_Mint.sdr
Code:
...
You get the idea.
 
Old 11-28-2023, 09:52 PM   #12
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
This is what I'd wanted from the configuration.
 
Old 11-28-2023, 11:43 PM   #13
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
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.
 
Old 11-30-2023, 12:32 PM   #14
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,423

Original Poster
Blog Entries: 43

Rep: Reputation: 36
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.
 
Old 11-30-2023, 02:18 PM   #15
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Quote:
Originally Posted by des_a View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Standard Scripts for Linux: Bash Script to List all Files Inside a Directory, Line by Line to Standard Output des_a Programming 13 01-12-2024 06:25 PM
LXer: Debugging Shell Scripts in Linux LXer Syndicated Linux News 0 02-23-2015 08:33 PM
[SOLVED] Effective debugging or improving ones debugging skills Ajit Gunge Programming 3 05-22-2009 09:29 AM
Difference between kernel - debugging and application debugging topworld Linux - Software 2 03-30-2006 12:50 AM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 10:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration