Sponsored Content
Top Forums UNIX for Advanced & Expert Users Function not called when no arguments is passed Post 302518846 by ygemici on Monday 2nd of May 2011 08:09:06 AM
Old 05-02-2011
Try this..

Code:
#!/bin/ksh
# Help message
#********************************************************************
usage() {
  print "Usage: $0 -i INP_FILE -o RPUIT_FILE"
  print "FTPing file to Mainframe"
  print "  -i INP_FILE    - file to be ftped"
  print "  -o RPUT_FILE   - Remote File Name"
  exit 1
  }
while getopts i:o: c
do
  case $c in
    i) INP_FILE=$OPTARG
       first=$c
       ;;
    o) RPUT_FILE=$OPTARG
       second=$c
       ;;
    ?) usage
       exit
       ;;
  esac
done
shift `expr $OPTIND - 2`
 
 if [ -z "$INP_FILE" ] && [ -z "$RPUT_FILE" ] ; then
  echo "Cause : first and second parameter are missing!!\n " ; usage
 elif [ -z "$RPUT_FILE" ] ; then
  echo "Cause : second parameter is missing!!\n " ; usage
 elif [ -z "$INP_FILE" ] ; then
  echo "Cause : first parameter is missing!!\n " ; usage
 fi
 
if [ "$first" != "i" ] &&  [ "$second" != "o" ]; then
  echo "Cause : first and second parameter are wrong!! \n" ; usage
 elif [ "$second" != "o" ] ; then
   echo "Cause : second parameter is wrong!! \n" ; usage
 elif [ "$first" != "i" ] ; then
  echo "Cause : first parameter is wrong!! \n" ; usage
 fi
 
if [ $# -ne 1 ] ; then echo "Cause : Arguments are exceed !! \n" ; usage ; fi

regards
ygemici
This User Gave Thanks to ygemici For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

pass arguments to called program

Thank you very much. (2 Replies)
Discussion started by: ShellUser
2 Replies

2. Shell Programming and Scripting

counting no of argumnts passed to a function

hi i have a function abc() { //from this function i am passing some args to another function def() } def() { //Now i need to calculate the no of input args and iterate through them } please help (4 Replies)
Discussion started by: satish@123
4 Replies

3. Shell Programming and Scripting

count no of arguments passed to a function

hi i have a function abc { //from this function i am passing args to antoher function like def a b c j k l } now i want to count the no of args coming to def() function and iterate over those values is there any way to do this one please help (2 Replies)
Discussion started by: satish@123
2 Replies

4. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

5. Shell Programming and Scripting

Return a value from called function to the calling function

I have two scripts. script1.sh looks -------------------------------- #!/bin/bash display() { echo "Welcome to Unix" } display ----------------------------- Script2.sh #!/bin/bash sh script1.sh //simply calling script1.sh ------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies

6. Shell Programming and Scripting

How to pass arguments to SQL file passed in shell script?

Hi, I am using SYBASE database. in my script i am connecting to DB via using isql. isql -U${S_USER} -S${S_SERV} -D${S_DB} -P${S_PWD} -b0 -w3000 -h0 -s"|" -i${MYDIR}/ABC.sql -oXYZ.txt << FINSQL i am taking a ABC.sql file to use the queries written in it and storing the output in... (3 Replies)
Discussion started by: dazdseg
3 Replies

7. Shell Programming and Scripting

Check if passed arguments is users

i want to check passed arguments one by one and if it is user print home director of that user (3 Replies)
Discussion started by: testman84
3 Replies

8. Red Hat

how can i know what arguments are passed to a pre install rpm script?

hi, i have an rpm, and i am looking at the presinstall script. i can see it takes in an argument, but what i do not know is how this argument is passed to the script? is there something that calls the preinstall script? i thought the preinstall script was the first thing executed. thanks (2 Replies)
Discussion started by: JamesByars
2 Replies

9. Shell Programming and Scripting

Deleting columns passed as arguments to the script

Hi all, I am trying to delete columns in a file using a script. The columns that need to be deleted are passed as arguments to the script. The script should look like this > delete_columns.sh <file_name.txt> <column_numbers_to_be_deleted> The contents of the file_name.txt will be like ... (5 Replies)
Discussion started by: VNR
5 Replies

10. Shell Programming and Scripting

How can multiple arguments be passed to shell script?

My requirement is that I want to pass similar argument to a shell script and process it in the script. Something like below: myScript.sh -c COMPONENT1 -c COMPONENT2 -a APPNote: -c option can be specified multiple times and -a is optional parameter I know this can be achieved using... (2 Replies)
Discussion started by: rajdeep_paul
2 Replies
set_values_hook()														 set_values_hook()

Name
  set_values_hook - obsolete Object method for handling changes to subpart resources.

Synopsis
  typedef Boolean (*XtArgsFunc)(Widget, ArgList, Cardinal *);
	 Widget w;
	 ArgList args;
	 Cardinal *num_args;

Inputs
  w	    Specifies the widget whose nonwidget resource values are to be changed.

  args	    Specifies the argument list that was passed to XtSetValues().

  num_args  Specifies the number of arguments in the argument list.

Returns
  True if the widget should be redrawn; False otherwise.

Availability
  Obsolete in Release 4 and later.

Description
  The set_values_hook() method is registered on the set_values_hook field of the Object, RectObj, or Core class part structure.  It is called
  by XtSetValues() after the class's set_values() method has been called.

  As of Release 4, the set_values_hook() method is obsolete, because the args and num_args arguments  are  now	passed	to  the  set_values()
  method.   Its  purpose  had  been to allow the value of subpart resources to be set from the argument list, by calling XtSetSubvalues() for
  example.

  The arguments to the set_values_hook() method are the widget and the argument list that were passed to XtSetValues().  The widget will have
  been	modified  by  any  superclass  methods	that have already been called.	It should return True if the change to subpart resources will
  require the widget to be redraw, and False otherwise.

  The set_values_hook() method is chained in superclass-to-subclass order and is called for compatibility with older widgets.  It  cannot  be
  inherited,  and  any new widget classes should set their set_values_hook field to NULL.  See XtSetValues(1) for details on when this method
  is called.  See set_values(4) for a discussion of setting the values of subpart resources, and other resources that do not  appear  on  the
  class resource list.

See Also
  XtSetSubvalues(1), XtSetValues(1),
  Core(3),
  set_values(4).

Xt - Intrinsics Methods 													 set_values_hook()
All times are GMT -4. The time now is 12:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy