Is it possible make the shell read functions 1 by 1 and calling an other function?
Greetings,
I m wondering if it's possible do do the following :
I have a simple function called "FindMoveDelete" which does the following :
So basicly it moves the variable "$FILENAME*.ext" to "$PATH/$VAR" and if the move succeeds, deletes the previous of said file directory. (which is basicly the same name)
Now, that's working but what I want to do next is load a configuration file containing a long list of functions. Each functions declaring new variables for $FILENAME $PATH and $VAR as follow :
That way when I want to modify or add new functions I simply have to edit my configuration file with all the functions...
Only problem is : How do I make the shell read function 1 then apply the MoveAndDelete then read function 2, apply MoveAndDelete.
I guess i could call the MoveAndDelete function within each function like so :
But it looks ugly
"Instead having 9,999 functions which do the same thing with slightly different values, just have your function take parameters."
- Well it's a good point and i would do that If I only wanted to do this action on only 1 particular kind of file but having "9.999 functions" allows me to run them all at once. If i don't want to use one I simply comment it. If I have to modify the subdirectory ($VAR) I simply edit the function.
Good point for the $PATH tho hum.. *hides switched it to $DIR.
"That code couldn't possibly work. '$FILENAME' in single quotes won't expand. 'FILENAME*' won't expand properly either."
- Indeed it's under double quotes in my script, wrote it back while writing this post, editing previous post..
"Why do you have -type d in one and not in the other?"
- To find my "$FILENAME*" directory and delete it. The name of the directory is basicly the same as the filename. It's set in each function.
At first I only move file with a specific extension (.ext) and if it succeeds, deletes the directory it was contained it.
For now the code is like this
What it does :
Move the files "name.of.file.and.dir*.ext" to "/volume1/my/dir/Subname" and then delete the directory "name.of.file.and.dir*"
I call every functions manualy and each of them contains the function FindMoveDelete.
It kinda looks ugly but it works. If you have a better idea I m all hears, at first I only wanted to run a file containing each of those functions for a script to read and end at the end of the file (loop?)
Anyways don't go knock your head on a wall for this, it was just a simple question at first. it's working as it is
Edit : Just took an other look at your last bit of code and it's interesting. Playing with IFS.. I ll test it out!
Thanks mate
Nop I run the script from my "in" directory only but yes for safety I ll modify the "find ." to "find /data/in" to avoid any problems.. If i happen to run it from other directories..
And no, I m not doing any "find" under $DIR/$SUBDIR I m just moving files there. Directories are already created.
Hello All,
I am trying to call a function from the calling main program from a dlopened library function, below is the entire code, when I execute it it crashes with sigill. Can you guys help me out I guess I am missing out on the linker flag or something here. besides I am new to AIX and... (1 Reply)
I need to
1.Open a csv
2.Process the csv i.e. Modify 2 column in the csv.
To modify the column the value needs to be passed to a pl/sql function and the return value should be updated
For eg:
If column 2 E,then E will be passed in database function
which will return Employee.
3. Write a... (5 Replies)
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)
hi guys, how r u???
please I need you, help me please.
I have a shell, in this shell i have this function and another code lines, this function is getting date one day back. the function is in the same shell (FILE 1)
Now I need put this function in another file (FILE 2) and calling... (4 Replies)
Hi,
I have a K shell
a.ksh
function abc {
// Some logic
}
In
b.ksh
i have included the a.ksh
./a.ksh
I want to call the abc function from this b.ksh script.
Thanks
Vijay (2 Replies)
Some Code
After Some code part is executed the control doesnt go to rvin_doxx_scrt.. and the script exits
rvin_doxx_scrt()
{
Some Code
}
if (som code)
... (4 Replies)
Hi,
I have a query ..
i have 2 scripts say 1.sh and 2.sh
1.sh contains many functions written using shell scripts.
2.sh is a script which needs to call the functions definded in 1.sh
function calls are with arguments.
Can some one tell me how to call the functions from 2.sh?
Thanks in... (6 Replies)
Hi,
I have searched the forum for the query, But i didnt find an exact answer.
I have a script(1.sh) and a c program(sample.c)
sample.c contains many function definitions.( run(), find(), add() etc).
I want to call functions in sample.c from 1.sh and use the return value in 1.sh... (3 Replies)
i have a function defined in one ksh (ksh 1)
i want to use that function in another ksh (ksh 2)
i am using
. $<directoryname>/<ksh name>
i am calling the function defined in ksh 1 in ksh 2
i want the returnstatus from the above operation
but it is not executing the function
what i... (1 Reply)
Is it possible to call a C function from within a shell script. This C function is part of an API. What do I need to make it work from my shell script. Anybody please help. (4 Replies)