Whiptail "Command not found"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Whiptail "Command not found"
# 8  
Old 03-15-2016
In your run.sh you refer to function/cleanup, where it actually is functions/actions/cleanup.
Also, your function-script 'server' sources itself, which should result in an endless loop.
I'd assume, the 2 function/s folders, and each their realted 'actions' folders might be the cause of your issue.

Furthermore, your cleanup script is executed upon sourcing.
Only the user check obviously, but if only that part needs root access, you should put that check inside the cleanup functon (so it only reports that if it is executed/called), or put the root check in the top script if it is a valid check for all of it.

Sourcing a file 'executes' it in the current shell/terminal/instance.
So all the echos not beeing within a function will be shown, and all the if-blocks be executed.

Serving a function possible means that the script only contains functions, so after sourcing they're available in the 'top-script'.
This allows to use the same variables within the sourced script as in the top script, without the need to re-define them.


Hope my 2 cents help.

On my own behalf, and to offer an alternative in case you do not like whiptail.
[url]https://savannah.nongnu.org/projects/tui/[/url]
[url]https://plus.google.com/u/0/communities/100234551346652779244[/url] ([I]the bg image gives a glimpse how it will look[/I])


Since you already have a project heavy relying on files, here's a TUI example based on files/folder structure:

Hint: (note the .sh extension is merly to indicate it is a file, and not a folder)
prj/setup/
prj/setup/run.sh
prj/setup/functions/ (provides files containing functions (& variable definitions) ONLY, so they may be called from scripts anywhere below ./menu/*)
prj/setup/menu
prj/setup/menu/default.info (content: "Please choose an item to work with:" ;; to inform the user about the context of this folder)
prj/setup/menu/birdie
prj/setup/menu/birdie/install.sh
prj/setup/menu/birdie/uninstall.sh

[U]./run.sh[/U] (simplified, absolute minimum)
[CODE]tui-browser -s ./functions -p ./menu ${@}[/CODE]
The -s functions would source all files found in ./functions
And open the 'browser' at ./menu showing the content of that directory.
If there were arguments passed to run.sh, it will work them through and pass remaining arguments to the dir/script found in the dir ./menu.

[U]./menu/birdie/install.sh[/U]
[CODE]functon_to_make_sure_birdie_is_in_the_repo
tui-asroot "tui-install -y birdie"[/CODE]
This would install 'birdie' on Arch, RH (based), Deb (based), Gentoo, *BSD and Solaris, if it is found in the regarding repositries, using either sudo if installed and user is in sudoers, or su if sudo is not installed or user not in sudoers.

If properly installed, and using absolute path names, or using localy with relative path names, one could call in the [U]terminal[/U]:
[CODE]run.sh birdie install.sh[/CODE]
Would execute ./menu/birdie/install.sh
Or browse there by calling [ICODE]run.sh[/ICODE] alone, and then type 1,1 (using the first menu entries each time (folder birdie, file install.sh)).
This would enable your users to either use the nice menu (incl location bar) or do the tasks straight from the cli.

Understand, this example is based on your current situation/provided info.

Last edited by sea; 03-15-2016 at 03:14 PM..
# 9  
Old 03-16-2016
Wow, that was a mouth full. I didn't touch it yesterday as I needed a break, but that's awesome to go on.

It seems this TUI is much more... Simple(r) then whiptail so I may switch to it, but I still don't fully grasp how to use it yet. As it currently seems I had a dead line but my job interfered so I wasn't able to reach it, so by hand it is and hopefully I'll be able to finish this script sooner or later (As I've been working on it for years)

Thanks so much for the help Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Problem on SQLplus command ""bash: sqlplus: command not found""

Hi all, i face an error related to my server ""it's running server"" when i use sqlplus command $ sqlplus bash: sqlplus: command not found the data base is up and running i just need to access the sqlplus to import the dump file as a daily backup. i already check the directory... (4 Replies)
Discussion started by: clerck
4 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

Bash Script giving "Command Not found"

Hello Geeks, Greetings...I have the following script: #!/usr/bin/bash #Script to generate number of active PDP context & calculate PDP activation #failurefrom EPG-M #Script written by Gbenga Adigun #September 12, 2013 username="xxxxxx" password="xxxxxxxxx" HOSTS=( ggsn01... (6 Replies)
Discussion started by: infinitydon
6 Replies

4. Shell Programming and Scripting

"Command not found" doing a while loop in bash/shell

i=0 numberofproducts=${#urls} #gets number of entries in array called "urls" numberofproductsminusone=`expr $numberofproducts - 1` #-subtract by one while do wget ${urls} i=$(( $i + 1 )) sleep 10 done I'm getting an error ./scrape: line 22: [0: command not found that... (3 Replies)
Discussion started by: phpchick
3 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Post Here to Contact Site Administrators and Moderators

What's happens with my thread about "-bash: ELF: command not found "?

Hi, Today, I've submitted a new tread in "Shell Programming and Scripting" forum, with title "-bash: ELF: command not found ". However, this thread has disappear. Can somebody give me an explanation? Regards. (3 Replies)
Discussion started by: Sonia_
3 Replies

7. Shell Programming and Scripting

How to distinguish between "command not found" and "command with no result"

system() call imeplemented in solaris is such a way that: Command not found - return code 1 Command executed successfully without Output - return code 1 how to distinguish between these two based on return code in a c - file? Can you help on this ? (5 Replies)
Discussion started by: iitmadhu
5 Replies

8. Shell Programming and Scripting

"-bash: sqlldr: command not found"

hi all, here i am trying to run one control file. but getting "-bash: sqlldr: command not found" error :confused: the code is given below. sqlldr $db_username/$db_password@$db_sid control=$loading_path/load_to_table.ctl log=loading.log can anybody help me in fixing the issue? ... (1 Reply)
Discussion started by: vinayakatj56
1 Replies

9. UNIX for Dummies Questions & Answers

why emacs caused "command not found" error

I installed Red Hat Enterprise Linux 5 on my PC. When i typed 'emacs' on the console, "command not found" error occurrd. Why. :mad: (1 Reply)
Discussion started by: cy163
1 Replies
Login or Register to Ask a Question