Sponsored Content
Full Discussion: Calling Function in KSH
Top Forums Shell Programming and Scripting Calling Function in KSH Post 302389364 by Scott on Sunday 24th of January 2010 02:03:08 PM
Old 01-24-2010
Hi.

Is the create function defined after the call to show_menu in your script?

i.e.

OK:
Code:
$ cat Test
create() {
  echo In create function
}

show_menu() {
  echo in show_menu function
  create
}

show_menu

$ ./Test
in show_menu function
In create function

OK:
Code:
$ cat Test
show_menu() {
  echo in show_menu function
  create
}

create() {
  echo In create function
}

show_menu

$ ./Test
in show_menu function
In create function

Not OK:
Code:
$ cat Test
show_menu() {
  echo in show_menu function
  create
}

show_menu

create() {
  echo In create function
}

$ ./Test
in show_menu function
./T: line 4: create: not found

 

10 More Discussions You Might Find Interesting

1. Programming

c++ calling main() function

i just finished a project for a c++ class that i wrote at home on my computer, compiled with gcc. when i brought the code into school it would not compile, it would complain that cannot call main() function. at school we use ancient borland c++ from 1995. anyway my program has 20 different... (3 Replies)
Discussion started by: norsk hedensk
3 Replies

2. Shell Programming and Scripting

Calling other file function

Hi, I am pretty new to unix. Lets say i have a program(run_program) that will call another file function(functiona, in same directory): hence, inside that run_program. i will just call "functiona xx xx" to refer and use that function. this run ok until i run this program from another folder.... (3 Replies)
Discussion started by: maldini
3 Replies

3. UNIX for Dummies Questions & Answers

Calling a function

I have created a file generic.func and it has lots of functions. One of the functions is this: Check_backup_size() { dsmc q b $BACKUP_DIR/"*.Z" | awk '{print $1}'|sed 's///g' > outputfile X=`awk '{sum += $1} END {print sum }' outputfile'` echo "$X" ls -ltr $BACKUP_DIR/"*.Z" | awk... (5 Replies)
Discussion started by: ashika
5 Replies

4. UNIX for Dummies Questions & Answers

Calling on function from file??

This may sounds dumb, but can I call on a function from a file? For example, I have a function file full of functions like below (no shell designation): func { echo "blah blah blah 1" } func2 { echo "blah blah blah 2" } func3 { echo "blah blah blah 3" } Am I able to call on any one... (3 Replies)
Discussion started by: douknownam
3 Replies

5. Shell Programming and Scripting

Return a value from called function to the calling function

I have two scripts. script1.sh looks -------------------------------- #!/bin/bash display() { echo "Welcome to Unix" } display ----------------------------- Script2.sh #!/bin/bash sh script1.sh //simply calling script1.sh ------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies

6. Shell Programming and Scripting

SHELL SCRIPT Function Calling Another Function Please Help...

This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord but only one record is getting wrote in DB.... Please advise ASAP...:confused: function InsertFtg { FTGSTR="" echo "Saurabh is GREAT $#" let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies

7. Shell Programming and Scripting

calling function with case

Hi I making a shell script and have some problem to start a function. echo "chose a number to download" read i; case $i in 1) head -1 ~/test3 | tail -1 > ~/test4;; 2) head -2 ~/test3 | tail -1 > ~/test4;; 3) head -3 ~/test3 | tail -1 >... (9 Replies)
Discussion started by: pelle
9 Replies

8. Shell Programming and Scripting

Calling two function

Hi, I need to run start_load function for two tables. Step 1: if HMAX_TBL_ID and GMAX_TBLI_D are same for tab_name1 then echo message "all table ids are processed" Step 2: go back and call start_load for tab_name2 and check if table id are same for table 2 too. Please let me know how to... (5 Replies)
Discussion started by: sandy162
5 Replies

9. Shell Programming and Scripting

Function is calling only once

In my prog if i enter the input for the 1st time it is executing correctly, but for the second time entire script is not executing it just exiting my code is #!/bin/sh checkpo() { echo "Checking the entered PO to create output text file "; IFS=$'\n' set -f var=0 for i in $(cat... (3 Replies)
Discussion started by: Padmanabhan
3 Replies

10. Shell Programming and Scripting

Help to Modify File Name in each function before calling another function.

I have a script which does gunzip, zip and untar. Input to the script is file name and file directory (where file is located) I am reading the input parameters as follows: FILENAME=$1 FILEDIR=$2 I have created 3 functions that are as follows: 1) gunzip file 2) unzip file... (2 Replies)
Discussion started by: pinnacle
2 Replies
ObjScanner(3pm) 					User Contributed Perl Documentation					   ObjScanner(3pm)

NAME
Tk::ObjScanner - Tk data scanner SYNOPSIS
# regular use use Tk::ObjScanner; my $scanner = $mw->ObjScanner( -caller => $object, -title=>"windows") -> pack ; my $mw -> ObjScanner ( -caller => $object, -title => 'demo setting the scanner options', -background => 'white', -selectbackground => 'beige', -foldImage => $mw->Photo(-file => Tk->findINC('folder.xpm')), -openImage => $mw->Photo(-file => Tk->findINC('openfolder.xpm')), -itemImage => $mw->Photo(-file => Tk->findINC('textfile.xpm')), ) -> pack(-expand => 1, -fill => 'both') ; # non-intrusive scan style # user code to produce data Tk::ObjScanner::scan_object($mydata) ; # resume user code DESCRIPTION
The scanner provides a GUI to scan the attributes of an object. It can also be used to scan the elements of a hash or an array. This widget can be used as a regular widget in a Tk application or can be used as an autonomous popup widget that will display the content of a data structure. The latter is like a call to a graphical Data::Dumper. The scanner can be used in an autonomous way with the "scan_object" function. The scanner is a composite widget made of a menubar and Tk::HList. This widget acts as a scanner to the object (or hash ref) passed with the 'caller' parameter. The scanner will retrieve all keys of the hash/object and insert them in the HList. When the user double clicks on a key, the corresponding value will be added in the HList. If the value is a multi-line scalar, the scalar will be displayed in a popup text window. Code ref will be deparsed and shown also in the pop-up window. Tied scalar, hash or array internal can also be scanned by clicking on the middle button to open them. Weak references are recognized (See WeakRef for details) Autonomous widget scan_object( data ) This function is not exported and must be called this way: Tk::ObjScanner::scan_object($data); This function will load Tk and pop up a scanner widget. When the user destroy the widget (with "File -" destroy> menu), the user code is resumed. Constructor parameters "caller" The ref of the object or hash or array to scan (mandatory). (you can also use '"-caller"') "-title" The title of the menu created by the scanner (optional) "-background" The background color for subwidgets (optional) "-selectbackground" The select background color for HList (optional) "-itemImage" The image for a scalar item (optional, default 'file.xbm') "-foldImage" The image for a composite item (array or hash) when closed (optional, default 'folder.xbm') "-openImage" The image for a composite item (array or hash) when open (optional, default 'openfolder.xbm') "-show_menu" ObjScanner can feature a menu with 'reload' button, 'show tied info', 'view pseudo-hash' check box. (optional default 0). "-destroyable" If set, a menu entry will allow the user to destroy the scanner widget. (optional, default 1) . You may want to set this parameter to 0 if the destroy can be managed by a higher level object. This parameter is ignored if show_menu is unset. "-view_pseudo" If set, will interpret pseudo hashes as hash (default 0). This option is disabled for Perl 5.09 and later. "-show_tied" If set, will indicate if a variable is a tied variable. You can see the internal data of the tied variable by double clicking on the middle button. (default 1) WIDGET-SPECIFIC METHODS updateListBox Update the keys of the listbox. This method may be handy if the scanned object wants to update the listbox of the scanner when the scanned object gets new attributes. CAVEATS
The name of the widget is misleading as any data (not only object) may be scanned. This widget is in fact a DataScanner. ObjScanner may fail if an object involves a lot of internal perl magic. In this case, I'd be glad to hear about and I'll try to fix the problem. ObjScanner does not detect recursive data structures. It will just keep on displaying the tree until the user gets tired of clicking on the HList items. There's no sure way to detect if a reference is a pseudo-hash or not. When a reference is believed to be a pseudo-hash, ObjScanner will display the content of the reference like a hash. If the reference is should not be displayed like a pseudo-hash, you can turn off the pseudo-hash view with the check button on the top right of the widget. Aynway, pseudo-hashes are deprecated from perl 5.8.0. Hence they are also deprecated in ObjScanner. The icon used for tied scalar changes from scalar icon to folder icon when opening the object hidden behind the tied scalar (using the middle button). I sure could use a better icon for tied items. (hint hint) THANKS
To Rudi Farkas for all the improvements provided to ObjScanner. To Slaven Rezic for: o The propotype code of the pseudo-hash viewer. o The idea to use B::Deparse to view code ref. AUTHOR
Dominique Dumont, dominique.dumont@hp.com Copyright (c) 1997-2004,2007 Dominique Dumont. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
perl, Tk, Tk::HList, B::Deparse perl v5.10.1 2007-10-09 ObjScanner(3pm)
All times are GMT -4. The time now is 03:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy