Excuting UNIX Functions under several username and host


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Excuting UNIX Functions under several username and host
# 1  
Old 07-01-2008
Excuting UNIX Functions under several username and host

Hi,

I am facing a issue in one of my script, Please help me on the same. Below I have the example.

Example:
I have two functions(host(),user()) in a single file named test1.ksh

File Name: test1.ksh
host () {

HOST=`hostname`
echo "$HOST\n"
}
user () {

USER=`whoami`
echo "$USER\n"
}
Requirnment:

My requirnment is I need to excute the function host() on server1 under the username user1 and I need to excute the function user() on server2 under the username user2. How may I do this or if ther is any other optins please let me know.


From,
Sam
# 2  
Old 07-01-2008
Please read https://www.unix.com/unix-dummies-que...om-forums.html before posting, especially 5 and 6.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Not getting colorcode when excuting html in UNIX

Hi i have below code which i am running and the out i want should be in red color echo "<html>" >> ERROR_FILE.html echo "<Body>" >> ERROR_FILE.html nawk 'BEGIN{print "<table border="1">"} {print "<tr>"; print "<TD colspan="0" bgcolor="#DC143C">"; for(i=1;i<NF;i++)... (5 Replies)
Discussion started by: mirwasim
5 Replies

2. Programming

Getting username from an informix 4gl program in UNIX

How to get the user name of the Operating system from an Informix 4gl program. eg:- -rw-r----- 1 gkuser srth1 292 Jul 27 19:28 u1.txt i need to get gkuser as the result? (0 Replies)
Discussion started by: enriquegm82
0 Replies

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

4. Shell Programming and Scripting

sh script to get unix username of person executing it

Hi, I am writing a script, and I need to incorporate some logic where I can find out the unix username of the person who is executing the script. The issue is , a particular user could have "sesu" ed into a group id. for eg. root, and then executed the script. In that case, instead of root,... (5 Replies)
Discussion started by: neil.k
5 Replies

5. Shell Programming and Scripting

excuting the following code

hi i am trying the below code for the following |_ | |_ | |_ |_ | |_ |_ |_ | |_ |_ |_ |_ and for this code also * * * * * * * * * * * * * * * !/bin/bash #i = "*" (2 Replies)
Discussion started by: kullu
2 Replies

6. Shell Programming and Scripting

Recursive functions in Unix

Hi Guys, Is there a way to write a recursive function in unix? Thanks for your help in advance, Regards, Magesh. (1 Reply)
Discussion started by: mac4rfree
1 Replies

7. UNIX for Dummies Questions & Answers

unix functions

Hi All, i have two functions in my script. question() { num=`ps -e | grep ps | awk -F" " '{print $1}'` qno=`expr $num % 10` grade=grade1 cat grade1/$qno answer ${grade} ${qno} } answer() { grade=$1 qno=$2 ansno=`wc -l $grade/ans/$qno | cut -d' ' -f1` j=0 while do (1 Reply)
Discussion started by: Usha Shastri
1 Replies

8. Programming

Standard UNIX functions

Hi everybody, first of all i apologize if my thread's title doesn't make much sense,but i coudn't find a more appropriate name :) Then i apologize about my question,which probably will sound trivial for you :) :) I am working on a program which is being tested in Linux but the final target is... (2 Replies)
Discussion started by: Zipi
2 Replies

9. Programming

Similar functions in unix

Hi, I am windows programer. I have very basic knowledge of Unix OS. I have written an application in Windows which consists of Win32 API namely WideCharToMultiByte(..) and MultiByteToWideChar(..). I am interested to deploy my application in unix platform henceforth I need to know IS... (1 Reply)
Discussion started by: dayakarr
1 Replies

10. Programming

getting username from a c program in unix

How to get the user name of the Operating system from a c program. eg:- -rw-r----- 1 gkuser srth1 292 Jul 27 19:28 u1.txt i need to get gkuser as the result? (3 Replies)
Discussion started by: Rajeshsu
3 Replies
Login or Register to Ask a Question