Sponsored Content
Top Forums UNIX for Beginners Questions & Answers "Help debug the shell script" Post 303035746 by bghosh on Sunday 2nd of June 2019 01:19:31 AM
Old 06-02-2019
"Help debug the shell script"

Hello All,

I have got a section of shell script which was working earlier but now it is giving some different results:

Code:
MSG=

 while  true
 do
    themenu
    getchar =
 
   case $answer in
       1) export_Config_tables;;
	   2) export_config_tables_file;;
       3) export_Accounts_tables;;
       4) export_both_tables;;
	   5) load_config_tables;;
	   6) load_config_tables_file;;
	  x|X) break;;
	q|Q) break;;
	d|D) toggle_debug;;
         *) badchoice;;
  
   esac
  done
clear


------- the menu function ---------
themenu () {
clear
echo `date `
echo
echo " summit Data Extract utility   (SOPRA v1.1)"
echo
 echo
 echo  "1.  Extract summit configuration data only"    
 echo  "2.  Extract summit config data in flat files only"
 echo  "3.  Extract summit account data only"
 echo  "4.  Extract all data "
 echo  "5.  Load summit configuration data from Dump"    
 echo  "6.  Load summit config data from flat files only"
 echo
 echo
 echo  "x.  Exit"
 echo
 echo $MSG
 echo
 echo "Select option : ";
 }

------ the getchar function -----------------

getchar (){
    	stty raw
	answer=`dd bs=1 count=1 2> /dev/null `
	stty -raw
}	

------ the bad choice function -------
badchoice () {
 MSG="Invalid menu choice"
}

After executing the script, it displays the menu


Code:
<System date>

summit Data Extract utility   (SOPRA v1.1)

Code:
1.  Extract summit configuration data only    
 2.  Extract summit config data in flat files only
 3.  Extract summit account data only
 4.  Extract all data 
 5.  Load summit configuration data from Dump
 6.  Load summit config data from flat files only
 
 
 x.  Exit

 Select option :

User inputs 5, but it doesn't display on the screen and after pressing <Enter> 2-3 times, it displays the message : Invalid menu choice.

I am unable to figure out where it is causing problem ? The menu function executes fine, it causes problem when it enters getchar() function and the case statement.



Please suggest where it is going wrong and what I should correct in the script.

Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

No utpmx entry: you must exec "login" from lowest level "shell"

Hi I have installed solaris 10 on an intel machine. Logged in as root. In CDE, i open terminal session, type login alex (normal user account) and password and i get this message No utpmx entry: you must exec "login" from lowest level "shell" :confused: What i want is: open various... (0 Replies)
Discussion started by: peterpan
0 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

3. AIX

"too big" and "not enough memory" errors in shell script

Hi, This is odd, however here goes. There are several shell scripts that run in our production environment AIX 595 LPAR m/c, which has sufficient memory 14GB (physical memory) and horsepower 5CPUs. However from time to time we get the following errors in these shell scripts. The time when these... (11 Replies)
Discussion started by: jerardfjay
11 Replies

4. UNIX for Advanced & Expert Users

kernel debug:"Symbol file not found for *.ko"

When I debug vmlinux with gdb, after it connect to the target, I got below output: usbcore.ko: No such file or directory. Error while mapping shared library sections: ohci_hcd.ko: No such file or directory. Symbol file not found for usbcore.ko Symbol file not found for ohci_hcd.ko Symbol... (2 Replies)
Discussion started by: yanglei_fage
2 Replies

5. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

6. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

7. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. 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

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

10. Shell Programming and Scripting

Poll Wacom input from "libinput debug-events" in Bash

Hey, I am making a Bash shell script to grab input from libinput. There's a few reasons why I am doing it this way: Using Python with python-libinput does not work. I installed version 0.1.0 with pip, and it complains about "ContextType" not existing. So that's a no-go. I am trying to get... (2 Replies)
Discussion started by: mrjpaxton
2 Replies
MSSQL_FETCH_FIELD(3)													      MSSQL_FETCH_FIELD(3)

mssql_fetch_field - Get field information

SYNOPSIS
object mssql_fetch_field (resource $result, [int $field_offset = -1]) DESCRIPTION
mssql_fetch_field(3) can be used in order to obtain information about fields in a certain query result. PARAMETERS
o $result - The result resource that is being evaluated. This result comes from a call to mssql_query(3). o $field_offset - The numerical field offset. If the field offset is not specified, the next field that was not yet retrieved by this function is retrieved. The $field_offset starts at 0. RETURN VALUES
Returns an object containing field information. The properties of the object are: o name - column name. if the column is a result of a function, this property is set to computed#N, where #N is a serial number. o column_source - the table from which the column was taken o max_length - maximum length of the column o numeric - 1 if the column is numeric o type - the column type. EXAMPLES
Example #1 mssql_fetch_field(3) example <?php // Connect to MSSQL and select the database mssql_connect('MANGOSQLEXPRESS', 'sa', 'phpfi'); mssql_select_db('php'); // Send a select query to MSSQL $query = mssql_query('SELECT * FROM [php].[dbo].[persons]'); // Construct table echo '<h3>Table structure for 'persons'</h3>'; echo '<table border="1">'; // Table header echo '<thead>'; echo '<tr>'; echo '<td>Field name</td>'; echo '<td>Data type</td>'; echo '<td>Max length</td>'; echo '</tr>'; echo '</thead>'; // Dump all fields echo '<tbody>'; for ($i = 0; $i < mssql_num_fields($query); ++$i) { // Fetch the field information $field = mssql_fetch_field($query, $i); // Print the row echo '<tr>'; echo '<td>' . $field->name . '</td>'; echo '<td>' . strtoupper($field->type) . '</td>'; echo '<td>' . $field->max_length . '</td>'; echo '</tr>'; } echo '</tbody>'; echo '</table>'; // Free the query result mssql_free_result($query); ?> SEE ALSO
mssql_field_seek(3). PHP Documentation Group MSSQL_FETCH_FIELD(3)
All times are GMT -4. The time now is 01:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy