return value problem


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users return value problem
# 1  
Old 06-30-2007
return value problem

hi ,
Consider the following code
#!/bin/sh

# addagenda

isMonthName()
{
case $(echo $1 | tr '[[:upper:]]' '[[:lower:]]') in
jan*|feb*|mar*|apr*|may*|jun*) return 0 ;;
jul*|aug*|sep*|oct*|nov*|dec*) return 0 ;;
*) return 1 ;;
esac
}

echo -n "Enter Day of event "
read word1

x=isDayName $word1
echo $x

In the above script when i print the value of x ,Null value is getting printed.(It should print 0 or 1)

any help pls.
Cheers
RRK
# 2  
Old 06-30-2007
Quote:
Originally Posted by ravi raj kumar
x=isDayName $word1
echo $x
try the following

Code:
isDayName $word1 
x=$?
echo $x

# 3  
Old 06-30-2007
hi poter,
Thanks a lot.
It worked.
cheers
RRK
# 4  
Old 07-01-2007
Quote:
isDayName $word1
x=$?
echo $x
Code:
isDayName $word1  >/dev/null  # If you don't want the output of this command to be displayed on the console
x=$?
echo $x

kamitsin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Return: can only `return' from a function or sourced script

Not sure where the problem is. I can run the script without any issue using the following command. . /opt/app/scripts/cdc_migration.sh But it fails with the below error when I try it this way /opt/app/scripts/cdc_migration.sh /opt/app/scripts/cdc_migration.sh: line 65: return: can only... (1 Reply)
Discussion started by: svajhala
1 Replies

2. Shell Programming and Scripting

Problem saving return value of subroutine in perl

Hi all, I have this code #This program read the triplets from file named "data" into #an array of array. use strict; use warnings; use Data::Dumper; use Graph; use Graph::Subgraph; my @S; while (<>) { push @S, ; } print "-----TRIPLETS-------\n"; print Dumper \@S; #Make... (6 Replies)
Discussion started by: rushadrena
6 Replies

3. Shell Programming and Scripting

some strange problem with return data in script

Hi, I have come across a little strange problem in my script. i tried the same logic in some other script where its working fine. but in other script its not behaving as expected. Here is the code: #!/bin/bash run_count="2" catalog_name="demo" cd... (3 Replies)
Discussion started by: sukhdip
3 Replies

4. Programming

Problem with implementing the times() function in C (struct tms times return zero/negative values)

Hello, i'm trying to implement the times() function and i'm programming in C. I'm using the "struct tms" structure which consists of the fields: The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process. The tms_stime structure... (1 Reply)
Discussion started by: g_p
1 Replies

5. Shell Programming and Scripting

Problem with call of Java Programm & return code handling & output to several streams.

Hello Everybody, thanks in advance for spending some time in my problem. My problem is this: I want to call a java-Programm out of my shell skript, check if die return code is right, and split the output to the normal output and into a file. The following code doesn't work right, because in... (2 Replies)
Discussion started by: danifunny
2 Replies

6. Shell Programming and Scripting

Scripting problem - when the file is not found i want it to return to the menu

when the file is not found i want it to return to the menu, however it carries out the next line when i hit a key I know its probably something simple can anyone help? here is my pause function: function pause(){ read -s -n 1 -p "Press any key to return to Menu . . ." echo } SCRIPT... (2 Replies)
Discussion started by: Alendrin
2 Replies

7. Shell Programming and Scripting

sed and character return problem

Hi, I have a problem with sed. It doesn't recognize the "\n" character. It substitudes an "n", instead of introducing a new line. This doesn't happend with print $ print "test \n \n" (it deos introduce two lines after hello) (AIX) $ sed s/bc/\n/g test.1 >test.2 $ cat test.1 bcdefg... (3 Replies)
Discussion started by: Santiago
3 Replies

8. UNIX for Dummies Questions & Answers

to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's

Hi All, Can anyone please let me know the syntax / how to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 'system()' function and '${?}'. I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode'... (0 Replies)
Discussion started by: manas6
0 Replies

9. Shell Programming and Scripting

problem in the return of grep

hi, i am running this command inside the script var=`grep -il $1 "${logdir}"* | xargs grep -ivl adding | xargs grep -ivl equation | xargs ls -ctr | tail -1` in that grep will find the latest logfile for the variable "$" if it fnd the logfile, then it reutrns the filename to the var if... (1 Reply)
Discussion started by: mail2sant
1 Replies

10. UNIX for Advanced & Expert Users

if (( $# != 1 )) ---- what will this return

Hi this is an existing code written by somebody. Please help me in understanding the meaning of this if (( $# != 1 )) (3 Replies)
Discussion started by: satgur
3 Replies
Login or Register to Ask a Question