Can I create a function to return non-interger value in shell script?
for example,
function getcommand ()
{
echo "read command"
read command
echo $command
}
command=$(getcommand)
I tried to do something as above. The statement echo "read command" does not show up.
... (5 Replies)
I want to look into a folder to see if there are any folders within it. If there are, I need to check inside each folder to see if it contains a .pdf file
So
If /myserver/myfolder/
contains a folder AND that folder conatins a .pdf file
do X
Else
do Z
I may have multiple folders and... (4 Replies)
Hi
I have a small function which returns a wrong value.
The function tries to make a connection to oracle database and tries to get the open_mode of the database in the variable status.
However when a database is down the value of the status column is set to READWRITE i am not sure why.
I... (0 Replies)
I need help to store the value returned from the function to one variable and then use that variable.
PREVIOUS_DATE_FUNCTION()
{
date '+%m %d %Y' |
{
read MONTH DAY YEAR
DAY=`expr "$DAY" - 1`
case "$DAY" in
0)
MONTH=`expr "$MONTH" - 1`
case... (1 Reply)
Hi,
I need to return a value from the function. the value will be the output from cat command which uses random fucntion.
#!/bin/ksh
hello()
{
var1=$(`cat /dev/urandom| tr -dc 'a-zA-Z0-9-!%&()*+,-/:;<=>?_'|fold -w 10 | head -n 1`)
echo "value is" var1
return var1
}
hello
var=$?... (2 Replies)
I'm having a little trouble returning a value from a function or calling it, I'm not quite sure.
I'm calling the function here
function region_lookup_with_details {
results = $(set_region)
echo $results
}
This is the function I'm calling
function set_region {
... (8 Replies)
I have two DNS resolvers in /etc/resolv.conf file. The top one is Windows DNS server, and the bottom one is my wi-fi router. Please see below. nameserver 192.168.1.126 nameserver 192.168.1.1
In Windows DNS server, the sole "Forward Lookup Zone" is biman.net
When I query for host in the zone... (6 Replies)
Discussion started by: broy32000
6 Replies
LEARN ABOUT OSF1
dlsym
dlsym(3) Library Functions Manual dlsym(3)NAME
dlsym - Obtain the address of a symbol from a dlopen() object
SYNOPSIS
#include <dlfcn.h>
void *dlsym(void *handle, const char *name)
PARAMETERS
The value returned from a call to dlopen() (and which has not since been released by a call to dlclose()). The name (character string) of
the symbol being sought.
DESCRIPTION
The dlsym function allows a process to obtain the address of a symbol defined within an object made accessible by a dlopen() call.
The dlsym function will search for the named symbol in all objects loaded automatically as a result of loading the object referenced by
handle (see dlopen(3)). Load ordering is used in dlsym() operations upon the global symbol object. The symbol resolution algorithm used
will be in dependency order as described in dlopen().
RETURN VALUE
The dlsym() function will return NULL, if handle does not refer to a valid object opened by dlopen() or if the named symbol cannot be found
within any of the objects associated with handle. More detailed diagnostic information is available through dlerror().
ERRORS
No errors are defined.
EXAMPLES
The following example shows how one can use dlopen() and dlsym() to access either function or data objects. For simplicity, error checking
has been omitted.
void *handle;
int *iptr, (*fptr)(int);
/* open the needed object */
handle = dlopen("/usr/home/me/libfoo.so.1", RTLD_LAZY);
/* find the address of function and data objects */
fptr = (int (*)(int))dlsym(handle, "my_function");
iptr = (int *)dlsym(handle, "my_object");
/* invoke function, passing value of integer as a parameter */
(*fptr)(*iptr);
APPLICATION USAGE
Special-purpose values for handle are reserved for future use. These values and their meanings are: Specifies the next object after this
one that defines name. This one refers to the object containing the invocation of dlsym(). The next object is the one found upon the
application of a load order symbol resolution algorithm (see dlopen(3)). The next object is either one of global scope - because it was
introduced as part of the original process image or because it was added with a dlopen() operation including the RTLD_GLOBAL flag) - or an
object that was included in the same dlopen() operation that loaded this one. The RTLD_NEXT flag is useful to navigate an intentionally
created hierarchy of multiply defined symbols created through interposition. For example, if a program wished to create an implementation
of malloc() that embedded some statistics gathering about memory allocations, such an implementation could use the real malloc() definition
to perform the memory allocation - and itself only embed the necessary logic to implement the statistics gathering function.
NOTES
Use of the dlsym routine is the preferred mechanism for retrieving symbol addresses. This routine reliably returns the current address of
a symbol at any point in the program, while the dynamic symbol resolution described previously might not function as expected due to com-
piler optimizations. For example, the address of a symbol might be saved in a register prior to a dlopen call, and the saved address might
then be used after the dlopen call - even if the dlopen call changed the resolution of the symbol.
RELATED INFORMATION dlclose(3), dlerror(3), dlopen(3). delim off
dlsym(3)