I have the script as below
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++).
I have the script as below
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.
Isn't possibe to decare prototype kind of statement as we do in C++ ?
Because the code I have posted should be as it is. I can not put the functions before calling.
Can we let the program know that we are going to use Hello function before funtion command executed.
Isn't possibe to decare prototype kind of statement as we do in C++ ?
Nope.
C++ can do that because it's a compiled language. It can assume that "okay, there's a function named xyzzy, I can find its contents later". When the program gets linked together into an exe, it has to actually go find all these libraries to do so.
Shell language runs immediately with no compilation step. If those functions don't already exist, they don't exist. (A few shells might have special features here. These features do not exist in general.)
Even C++ can't manage if you don't tell it what the functions actually are though! At the very least you have to #include <something> before you use them, for it to even assume they exist. You can do something like #include in shell. Put your function, or a bunch of functions, in another file then do this:
Note the space between the dot and everything else, that's essential.
script-name will be run in your current shell, effectively loading the functions in it.
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)
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)
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)
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)
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)
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)
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)