Sponsored Content
Top Forums Shell Programming and Scripting Calling external function in a shell Post 302282989 by acevallo on Monday 2nd of February 2009 10:31:05 AM
Old 02-02-2009
Computer Calling external function in a shell

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 this function from the FILE 1, in another words I want to save all functions in a same file, and calling them from a main file.

PLEASE GUYS HELP ME, I am new in this forum, if I have mistakes with rules I hope to do better my posts, je je je j Smilie

-----------------------

get_one_day_before_specified_date()
{
#get the command line input(date month & year)
day=$1
month=$2
year=$3
# if it is the first day of the month
if [ $day -eq 01 ]
then
# if it is the first month of the year
if [ $month -eq 01 ]
then
# make the month as 12
month=12
# deduct the year by one
year=`expr $year - 1`
if [ $year -lt 10 ]
then
year=0$year
fi
else
# deduct the month by one
month=`expr $month - 1`
fi
if [ $month -lt 10 ]
then
month=0$month
fi
# use cal command, discard blank lines,
# take last field of last line,
# first awk command is used to get the
# last useful line of the calendar cmd,
# second awk command is used to get the
# last field of this last useful line,
# NF is no. of fields,
# $NF is value of last field
day=`cal $month $year | awk 'NF != 0{ last = $0 }; END{ print last }' | awk '{ print $NF }'`
else
# deduct the day by one
day=`expr $day - 1`
fi
if [ $day -lt 10 ]
then
day=0$day
fi
fecha_before=$day'-'$month'-'$year
return $fecha_before
}


-----------------------
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

calling a c function from shell

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)
Discussion started by: seshagiri
4 Replies

2. UNIX for Dummies Questions & Answers

calling one function from another shell script

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)
Discussion started by: trichyselva
1 Replies

3. Shell Programming and Scripting

Calling a C-function froma shell script

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)
Discussion started by: jisha
3 Replies

4. Shell Programming and Scripting

calling a function in Shell script troubleshooting

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)
Discussion started by: ultimatix
4 Replies

5. 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

6. Homework & Coursework Questions

Shell script calling Perl function, sort and find data, write to new files

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I must write a shell script that calls two external Perl functions--one of which sorts the data in a file, and... (6 Replies)
Discussion started by: kowit010
6 Replies

7. Shell Programming and Scripting

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 : FindMoveDelete() { find . -iname "$FILENAME*.ext" -exec mv {} "$PATH/$VAR" \; && find . -maxdepth 1 -type d -iname "$FILENAME*" -exec rm -rf {}... (6 Replies)
Discussion started by: Sekullos
6 Replies

8. Shell Programming and Scripting

Calling a function in cpp file inside shell script

Hi I need to call a function written in a cpp file with arguments inside the shell script..Can anyone help me how to do this:( (1 Reply)
Discussion started by: rkrish
1 Replies

9. Shell Programming and Scripting

Calling Pl/sql function in shell script to modify csv

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)
Discussion started by: Chinky23
5 Replies

10. Shell Programming and Scripting

Multithreading - Calling user function with xargs in korn shell

I know there are other ways of accomplishing the below task, but the purpose of this thread is to understand the below code. I wanted to use xargs with user defined function in korn shell. Am aware, that I could write custom function into a script and place it in FPATH and then call it in xargs,... (2 Replies)
Discussion started by: luhah
2 Replies
Gtk2::Calendar(3)					User Contributed Perl Documentation					 Gtk2::Calendar(3)

NAME
Gtk2::Calendar HIERARCHY
Glib::Object +----Glib::InitiallyUnowned +----Gtk2::Object +----Gtk2::Widget +----Gtk2::Calendar INTERFACES
Glib::Object::_Unregistered::AtkImplementorIface Gtk2::Buildable METHODS
widget = Gtk2::Calendar->new $calendar->clear_marks (year, month, day) = $calendar->get_date $calendar->set_detail_func ($func, $data=undef) o $func (scalar) o $data (scalar) Since: gtk+ 2.14 integer = $calendar->get_detail_height_rows Since: gtk+ 2.14 $calendar->set_detail_height_rows ($rows) o $rows (integer) Since: gtk+ 2.14 integer = $calendar->get_detail_width_chars Since: gtk+ 2.14 $calendar->set_detail_width_chars ($chars) o $chars (integer) Since: gtk+ 2.14 $calendar->display_options ($flags) o $flags (Gtk2::CalendarDisplayOptions) The old name for "set_display_options". calendardisplayoptions = $calendar->get_display_options $calendar->set_display_options ($flags) o $flags (Gtk2::CalendarDisplayOptions) $calendar->freeze boolean = $calendar->mark_day ($day) o $day (integer) $widget->marked_date ($value) value = $widget->marked_date $widget->month ($value) value = $widget->month $widget->num_marked_dates ($value) value = $widget->num_marked_dates $calendar->select_day ($day) o $day (integer) boolean = $calendar->select_month ($month, $year) o $month (integer) o $year (integer) $widget->selected_day ($value) value = $widget->selected_day $calendar->thaw boolean = $calendar->unmark_day ($day) o $day (integer) $widget->year ($value) value = $widget->year PROPERTIES
'day' (integer : readable / writable / private) The selected day (as a number between 1 and 31, or 0 to unselect the currently selected day) 'detail-height-rows' (integer : readable / writable / private) Details height in rows 'detail-width-chars' (integer : readable / writable / private) Details width in characters 'month' (integer : readable / writable / private) The selected month (as a number between 0 and 11) 'no-month-change' (boolean : readable / writable / private) If TRUE, the selected month cannot be changed 'show-day-names' (boolean : readable / writable / private) If TRUE, day names are displayed 'show-details' (boolean : readable / writable / private) If TRUE, details are shown 'show-heading' (boolean : readable / writable / private) If TRUE, a heading is displayed 'show-week-numbers' (boolean : readable / writable / private) If TRUE, week numbers are displayed 'year' (integer : readable / writable / private) The selected year SIGNALS
month-changed (Gtk2::Calendar) day-selected (Gtk2::Calendar) day-selected-double-click (Gtk2::Calendar) prev-month (Gtk2::Calendar) next-month (Gtk2::Calendar) prev-year (Gtk2::Calendar) next-year (Gtk2::Calendar) ENUMS AND FLAGS
flags Gtk2::CalendarDisplayOptions o 'show-heading' / 'GTK_CALENDAR_SHOW_HEADING' o 'show-day-names' / 'GTK_CALENDAR_SHOW_DAY_NAMES' o 'no-month-change' / 'GTK_CALENDAR_NO_MONTH_CHANGE' o 'show-week-numbers' / 'GTK_CALENDAR_SHOW_WEEK_NUMBERS' o 'week-start-monday' / 'GTK_CALENDAR_WEEK_START_MONDAY' o 'show-details' / 'GTK_CALENDAR_SHOW_DETAILS' SEE ALSO
Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gtk2::Widget COPYRIGHT
Copyright (C) 2003-2008 by the gtk2-perl team. This software is licensed under the LGPL. See Gtk2 for a full notice. perl v5.12.1 2010-07-05 Gtk2::Calendar(3)
All times are GMT -4. The time now is 03:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy