Sponsored Content
Top Forums Shell Programming and Scripting Function prototype declaration Post 302866491 by Akshay Hegde on Tuesday 22nd of October 2013 05:36:52 AM
Old 10-22-2013
Quote:
Originally Posted by Balasankar
Hi All,

I have the script as below
Code:
#!bin/bash
let k=9
if [ $k -eq 9 ]
then
echo "Start"
Hello
echo "End"
else
echo "failed"
fi
function Hello() {
echo "hello !!!!"
}

I got the below error :
Start
Testtt.sh: line 6: Hello: command not found
End

Could any one help me how can I define the function after the main process. If I put the function definition before the main process it would work but I need the program structure as it is. If you could help to delcare any prototype to intimate the shell the I am going to use the function in later part of the program (as we declare prototype in C++).

Thanks in advance!!!


Function should be defined before calling. as you might aware commands are executed sequentially.

modify like this

Code:
#!bin/bash

function Hello(){
        echo "hello "
            }

let k=9
if [ $k -eq 9 ]
then
    echo "Start"
    Hello
    echo "End"
else
    echo "failed"
fi

 

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Solaris pkgmk -> prototype errors...

I'm attempting to create another package (i.e. for utilizing pkgadd/pkgrm/pkgchk/etc.) But after creating the prototype file, I noticed that some of my files begin with the '=' character. How do I get pkgmk to interpret the "/path/=file" as a single file, rather than interpreting it as... (7 Replies)
Discussion started by: mslightn
7 Replies

2. Programming

gcc warnings: implicit declaration of function...

I am having strange warnings from gcc compiler, which I don't think should come while cmpiling. Can anyone help? The warnings are: - warning: implicit declaration of function 'bzero' - warning: implicit declaration of function 'inet_addr' The code is as below: int main(int argc, char... (2 Replies)
Discussion started by: Ahsan
2 Replies

3. UNIX for Dummies Questions & Answers

Pkgmk....question on prototype file

I've read the man page, but still unclear a bit.... I'm making some packages of files. My pkginfo file has a line BASEDIR=/base/path. I also have several prototype files (depending on the package), that either list the destination path as absolute: f non /abs/path/to/go/here/file1 or are... (0 Replies)
Discussion started by: Yinzer955i
0 Replies

4. Programming

implicit declaration of function 'reboot'

Hi, I'm tying to use the following function to reboot the system as part of my code #include <unistd.h> #include <linux/reboot.h> int restart(unsigned int delay) { sleep(delay); return reboot(LINUX_REBOOT_CMD_RESTART); } When I try to compile the code I get the warning in the... (2 Replies)
Discussion started by: galapogos
2 Replies

5. UNIX for Dummies Questions & Answers

difficult problem with function declaration

Hello, I have a problem with the declaration of a function. This is how I declare the function : c:63: void foo(threadpool *tp,void (*func)(void*), (void*)arg); Inside main, I call it like this: main(){ .......... threadpool y; c:104: ... (4 Replies)
Discussion started by: garag11
4 Replies

6. What is on Your Mind?

My Charts in the Prototype Vue.js UserCP

Yea.... something I thought would take me an hour ended up taking most of the day. Well, it's not like those YT video tutorials where it take a week or more to make a video and the guys (gals) make it look so easy. But having said that, I'm happy to share with forum members the first "My... (6 Replies)
Discussion started by: Neo
6 Replies

7. What is on Your Mind?

Major Changes in New UserCP (v0.63) Prototype

Regarding the latest version of the UserCP prototype (version 0.63) I have made a lot of major changes, including Added a "Posts Timeline" table for the recent posts, complimenting the non-table version earlier, which has been moved off the main menu (link at the bottom of the table). Added a... (4 Replies)
Discussion started by: Neo
4 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.11 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 12:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy