return string in functions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting return string in functions
# 1  
Old 05-15-2008
CPU & Memory return string in functions

Hi friends

I need to return string value in functions
can anyone help me out to return string values rather than integer.

#!/bin/bash
add_a_user()
{
USER=$1
COMPANY=$2
shift; shift;
echo "Adding user $USER ..."
echo "$USER working in $COMPANY ..."
ret_type=YES
return $ret_type
}
echo "Start of script..."
add_a_user kittu Google
echo "End of script..."

i need your valuable suggesions please.
Thanks
Kittu
# 2  
Old 05-15-2008
Print them and call the function in backticks. Return codes from functions and programs are small integers 0-255.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

2. Programming

How to pass int and return string in C?

hi I want to write a function which takes int as input and returns a string like this. char GetString(int iNo) { switch(iNo) { case 0: return "Zero"; break; case 1: return "One"; break; } } void main() { int i; printf("Enter... (1 Reply)
Discussion started by: atharalikhan
1 Replies

3. Shell Programming and Scripting

return part of a string in bash

Hi, I would like to return the last part of a string in an array of strings in bash. The array contains in each position the content below: and I would like to return only the last part of each string. The correct result would be: How can I do that in bash using AWK?... (7 Replies)
Discussion started by: anishkumarv
7 Replies

4. Shell Programming and Scripting

How to return a string?

function blah { return "string" } it keeps saying string: not found How can i do this guys? Because I'm trying to do something like this function print_daemon_options { echo "Start Daemons - Please enter one or a combination of the following:" if isDatasubEnabled &&... (11 Replies)
Discussion started by: pyscho
11 Replies

5. UNIX for Dummies Questions & Answers

search for string and return substring

Hi, I have a file with the following contents: I need to create a script or search command that will search for this string 'ENDC' in the file. This string is unique and only occurs in one record. Once it finds the string, I would like it to return positions 101-109 ( this is the date of... (0 Replies)
Discussion started by: Lenora2009
0 Replies

6. UNIX for Dummies Questions & Answers

Search for string and return lines above and below

Hi, I have a file with the following contents: COMPANY ABCD TRUCKER JOE SMITH TRUCK 456 PLATE A12345678 TRUCKER BILL JONES TRUCK 789 PLATE B7894561 I need to create a script or search command that will search for this string '789' in the file. This string is unique and only... (7 Replies)
Discussion started by: doza22
7 Replies

7. Shell Programming and Scripting

How to use string across functions in AWK

Hi , I m facing one problem with String usage in AWK . let me put what i need . i have a function and there i used one string ( meta_string) function 1 { ................... ................... meta_string = " this string got... (1 Reply)
Discussion started by: madhaviece
1 Replies

8. Shell Programming and Scripting

KSH Functions String return

Hy everybody I'm trying to write a function like function(){ final=$1 return $final } but I get following error: "return: bad non-numeric arg ''" what shall I do? Isn't it possible to return strings?:confused: thanks lucae (2 Replies)
Discussion started by: lucae
2 Replies

9. Shell Programming and Scripting

String search and return value from column

Dear All I had below mention file as my input file. 87980457 Jan 12 2008 2:00AM 1 60 BSC1 81164713 Jan 12 2008 3:00AM 1 60 BSC2 78084521 Jan 12 2008 4:00AM 1 60 BSC3 68385193... (3 Replies)
Discussion started by: jaydeep_sadaria
3 Replies

10. Shell Programming and Scripting

return line below string grepp'ed for

Hi there Does anybody know how to get grep to return the line underneath the string i am grepping for ie, if i have this file hello everybody how are you and i issue #cat file | grep how I would like it to return the line below (in this case the string "are") Is this... (2 Replies)
Discussion started by: hcclnoodles
2 Replies
Login or Register to Ask a Question