whoami export


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting whoami export
# 1  
Old 03-28-2011
whoami export

how can I use whoami on a script for ordinary user? it always says command not found. pls help

Code:
#!/bin/ksh
W='whoami'
DATE=`date "+%Y-%m-%d %H:%M:%S"`

echo " $DATE- by $W"

result

2011-03-29 09:46:16 -  by

you wil noticed the by is blank...pls help..but in root, it works
# 2  
Old 03-28-2011
Hey man, you got the code wrong. Change the single quote in W to `.

Code:
W=`whoami`
DATE=`date "+%Y-%m-%d %H:%M:%S"`

echo " $DATE- by $W"

Output:
2011-03-29 10:18:36- by ******
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Capture whoami log on a specific command

// AIX 6.1 TL8 Please advise on how to capture whoami log or the user and time info into a log file (i.e. /tmp/cmdcapture.log) whenever users are executing a certain command(s) so that I can keep the single log history (for all users) of who did what. The command(s) I need to monitor are a... (3 Replies)
Discussion started by: Daniel Gate
3 Replies

2. UNIX for Dummies Questions & Answers

Whoami error

when I type whoami i get an error saying ksh not found.. how do I exit from ksh script and make it work .. (2 Replies)
Discussion started by: lakers646
2 Replies

3. OS X (Apple)

sudo chown -R `whoami` /usr/local

I was following a tutorial on installing Homebrew and I changed the ownership of /usr/local/ to me. Now McAfee Security won't start This is the exact line I typed: sudo chown -R `whoami` /usr/local Then I tried to fix it with: sudo chown -R root /usr/local I still can't start mcafee. It say... (7 Replies)
Discussion started by: chancho
7 Replies

4. Ubuntu

How use export

Hello, I'm trying to use export for non use "./" when I execute a program. I mean "program" in place of "./program" I tried this: export doit=program But doesn't work the answer is: doit command not found Then, I see the variables using export, and I can see: ... (1 Reply)
Discussion started by: NewBe
1 Replies

5. Shell Programming and Scripting

export. I know it, but...

Hello, I have the following command at the "Shell": export PATH=${PATH}:${ANT_HOME}/bin I know what "export" does and the ANT_HOME part. But, regarding the following part: ${PATH} What is "PATH" Supposed to be here. In other words, what is the value of "PATH". As far as for... (4 Replies)
Discussion started by: SWEngineer
4 Replies

6. Shell Programming and Scripting

Finding whoami

Hello I have a question about shell programming So I recently found out that someone is secretly accessing my files due to my mistake. Of course, now, I changed all the permission so people cannot access my file(s) anymore. However, I am a little bit mad about the fact and I'd like to find that... (1 Reply)
Discussion started by: chun02160
1 Replies

7. Shell Programming and Scripting

About export

Hi all, I am calling a script from main script. The called script (second script) have to return some value, i can use exit to pass but in exit i have to pass some other value. i used "export Var", but this command resides in a function of second script. could you please tell me how to... (3 Replies)
Discussion started by: Arunprasad
3 Replies

8. UNIX for Dummies Questions & Answers

The "Whoami" command

Ladies, Gents, I am fairly new to this game but I am having trouble making the above command work. If I login as root and go to terminal session "whoami" works. If I login as admin open a terminal session and "su root" the "whoami" command comes up with " Not recognised". Any ideas? ... (1 Reply)
Discussion started by: John Dobson
1 Replies

9. BSD

How to export

Hi I need to export some directpry path like below: var1=/<>/<>/<> export var1 This is my basic idea. I tried export var1=/<>/<>/<> after executing this in a shell i did an echo of the var1. But nothing happened. Can you please help me with this. I need to srite a script to... (4 Replies)
Discussion started by: jisha
4 Replies

10. Shell Programming and Scripting

export???

I am trying to export the variable OBJ2 and set it to done. Can some one please let me how to do this? I have tried editing my .bashrc file with this echo <VARIABLE_NAME>=<"OBJ2"> But that wont seem to work... (1 Reply)
Discussion started by: Justinkase
1 Replies
Login or Register to Ask a Question