Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Help with if else statement... Post 303046358 by AgentOrange on Saturday 2nd of May 2020 10:27:50 AM
Old 05-02-2020
Thank you for your response vbe :-)


so I have


Code:
#!/bin/bash
printf "checking for hidden modules: "
for mm in /sys/module/*; do 
   if test -d ${mm}/sections; then 
      MOD="$(basename ${mm})"; 
      lsmod | grep -E "^${MOD}" > /dev/null || printf "[found hidden module] \n${MOD}\n"; 
   fi;
done

which works as expected. Problem is that:
1) if it doesn't find any modules, i cant figure out with this particular command how to make it say [ok] insted of
[found hidden module]
diamorphine
2) if it doesnt find any modules, it doesn't return a new line. Which would be solved also if I could figure out 1) !


Moderator's Comments:
Mod Comment Please use code tags, for you code and data, thanks

Last edited by vbe; 05-02-2020 at 01:44 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If statement

Hi, I have a statement in shell script which i am writing below: if ] then ..... What is the meaning of -a option in files, meaning of the statement in the if condition ] means. Thanks (3 Replies)
Discussion started by: dreams5617
3 Replies

2. Shell Programming and Scripting

if statement

can someone please tell me what is wrong with the below. i'm trying to get a script to run if the content of a variable is either small letter y or capital letter Y. if then whatever fi (4 Replies)
Discussion started by: Terrible
4 Replies

3. Shell Programming and Scripting

statement

I want to write a program that would convert yard to feet and feet to yard. i.e 1 yard = 3 * feet Echo "enter a" read a expr a *3 The trick is that I want to give the user some options. After the conversion from yard to feet is done, I want to ask the user whether or not he/she wants to... (10 Replies)
Discussion started by: Ernst
10 Replies

4. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

5. Shell Programming and Scripting

How is use sselect statement o/p in insert statement.

Hi All, I am using Unix ksh script. I need to insert values to a table using the o/p from a slelect statement. Can anybody Help! My script looks like tihs. ---`sqlplus -s username/password@SID << EOF set heading off set feedback off set pages 0 insert into ${TB_NAME}_D... (2 Replies)
Discussion started by: nkosaraju
2 Replies

6. UNIX for Dummies Questions & Answers

If statement (yes or no)

I have the program: #!/bin/ksh echo Please enter yes or no read n typeset -l n if ] then echo My name exit else echo delete my name fi Question: How can I make the program accept only the word "yes" or "no" otherwise it will ask the user to re-enter? Thanks! (7 Replies)
Discussion started by: bobo
7 Replies

7. Shell Programming and Scripting

If statement help

I'm trying to create a script that would allow me to identify the sucessful removal of a file. Here's what i put together so far, let me know if it's correct or not. FILE_NAME="cactus.dat" FILE_FIND='find / -name $FILE_NAME' if ;then echo "cactus.dat was not removed successfully" ... (3 Replies)
Discussion started by: sdpinoy
3 Replies

8. Shell Programming and Scripting

Statement

${PFILE}.backupfile Please tell me what the above statement means? (1 Reply)
Discussion started by: lg123
1 Replies

9. Shell Programming and Scripting

If statement

Hi, I have this code here. Its suppose to do something when certain condition is met, I'm pretty sure at least one of the condition will be meet somewhere in the loop but it always go to else part of the script. Is something wrong on this script? age_list=`tar -tvf /home/dir/$tarfile... (4 Replies)
Discussion started by: erin00
4 Replies

10. Shell Programming and Scripting

Convert Update statement into Insert statement in UNIX using awk, sed....

Hi folks, I have a scenario to convert the update statements into insert statements using shell script (awk, sed...) or in database using regex. I have a bunch of update statements with all columns in a file which I need to convert into insert statements. UPDATE TABLE_A SET COL1=1 WHERE... (0 Replies)
Discussion started by: dev123
0 Replies
Devel::Hide(3pm)					User Contributed Perl Documentation					  Devel::Hide(3pm)

NAME
Devel::Hide - Forces the unavailability of specified Perl modules (for testing) SYNOPSIS
use Devel::Hide qw(Module/ToHide.pm); require Module::ToHide; # fails use Devel::Hide qw(Test::Pod Test::Pod::Coverage); require Test::More; # ok use Test::Pod 1.18; # fails Other common usage patterns: $ perl -MDevel::Hide=Module::ToHide Makefile.PL bash$ PERL5OPT=MDevel::Hide bash$ DEVEL_HIDE_PM='Module::Which Test::Pod' bash$ export PERL5OPT DEVEL_HIDE_PM bash$ perl Makefile.PL outputs (like blib) Devel::Hide hides Module::Which, Test::Pod, etc. DESCRIPTION
Given a list of Perl modules/filenames, this module makes "require" and "use" statements fail (no matter the specified files/modules are installed or not). They die with a message like: Can't locate Module/ToHide.pm (hidden) The original intent of this module is to allow Perl developers to test for alternative behavior when some modules are not available. In a Perl installation, where many modules are already installed, there is a chance to screw things up because you take for granted things that may not be there in other machines. For example, to test if your distribution does the right thing when a module is missing, you can do perl -MDevel::Hide=Test::Pod Makefile.PL forcing "Test::Pod" to not be found (whether it is installed or not). Another use case is to force a module which can choose between two requisites to use the one which is not the default. For example, "XML::Simple" needs a parser module and may use "XML::Parser" or "XML::SAX" (preferring the latter). If you have both of them installed, it will always try "XML::SAX". But you can say: perl -MDevel::Hide=XML::SAX script_which_uses_xml_simple.pl NOTE. This module does not use Carp. As said before, denial dies. This module is pretty trivial. It uses a code reference in @INC to get rid of specific modules during require - denying they can be successfully loaded and stopping the search before they have a chance to be found. There are three alternative ways to include modules in the hidden list: o setting @Devel::Hide::HIDDEN o environment variable DEVEL_HIDE_PM o import() Optionally, you can propagate the list of hidden modules to your process' child processes, by passing '-from:children' as the first option when you use() this module. This works by populating "PERL5OPT", and is incompatible with Taint mode, as explained in perlrun. CAVEATS There is some interaction between "lib" and this module use Devel::Hide qw(Module/ToHide.pm); use lib qw(my_lib); In this case, 'my_lib' enters the include path before the Devel::Hide hook and if Module/ToHide.pm is found in 'my_lib', it succeeds. Also for modules that were loaded before Devel::Hide, "require" and "use" succeeds. Since 0.0005, Devel::Hide warns about modules already loaded. $ perl -MDevel::Hide=Devel::Hide -e '' Devel::Hide: Too late to hide Devel/Hide.pm EXPORTS Nothing is exported. ENVIRONMENT VARIABLES
DEVEL_HIDE_PM - if defined, the list of modules is added to the list of hidden modules DEVEL_HIDE_VERBOSE - on by default. If off, supresses the initial message which shows the list of hidden modules in effect PERL5OPT - used if you specify '-from:children' SEE ALSO
"perldoc -f require" Test::Without::Module BUGS
Please report bugs via CPAN RT http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-Hide <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-Hide>. AUTHORS
Adriano R. Ferreira, <ferreira@cpan.org> with contributions from David Cantrell <dcantrell@cpan.org> COPYRIGHT AND LICENSE
Copyright (C) 2005-2007 by Adriano R. Ferreira This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.4 2007-11-15 Devel::Hide(3pm)
All times are GMT -4. The time now is 11:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy