Solved

How to kuu to another id inside a shell script

Posted on 2010-09-20
7
2,833 Views
Last Modified: 2013-12-26
I need to kuu within a script and then exit from the kuu id within the same script. How can I do that?




#!/bin/ksh



cd ~



filename = $(ls -ltr | awk 'END{print $NF}'

kuu pfndqa

./run-dfp.sh qae2e first /v/TgtFiles/$filename

exit

cd /v/region/na/appl/

Open in new window

0
Comment
Question by:sunny82
  • 4
  • 3
7 Comments
 

Author Comment

by:sunny82
ID: 33720017
On doing kuu here, it is asking me for pasword but on putting the password, it should execute the following shell script. But it is not getting executed. After executing the shell script, it should then exit the kuu id
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 33721188
Hi,

I never heard of "kuu".

Seems that it does the same as "su", and with su it could look like this

#!/bin/ksh  
...
 ...
su pfndqa -c "./run-dfp.sh qae2e first /v/TgtFiles/$filename"
cd /v/region/na/appl/
...

wmp
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33721227
... and the statement in line 5 will most probably not do what you want.

I assume you're trying to find the newest file in the directory.
This is easier:

filename=$(ls -tr | tail -1)

Note that I removed the spaces around "=". They're not allowed when assigning variables.


0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:sunny82
ID: 33721549
Thx so much..let me try this tomorrow and I will let you know...I am assuming that after doing su and calling this shell script from another perl or shell script, it will ask for my password and after executing line 7 will exit the su and return to my actual user id. Am I correct?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33723314
Yes, correct.
Just note that everything you want to execute as pfndqa must appear after "-c" and must be enclosed in quotes.
In your case use double quotes, because there is the local variable $filename which needs to get expanded by the calling shell, not the subshell opened by "su".
Should you need double quotes inside the command executed via "su" escape them with a backslash (\")
You don't need an explicit "exit". When the command specified with -c "..." ends the subshell ends as well.
0
 

Author Comment

by:sunny82
ID: 33727693
great that helped a lot. Thx..I would like to know the difference between su and kuu...Don't both do the same thing?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33732800
I still have no idea what kuu actually is. Nerver heard of it before, and searching the web doesn't yield any suitable result.
Could it be that kuu is an alias or a link?
Please issue
alias kuu
type kuu
ls -l $(which kuu)
Any insight?
Thx for the points!
wmp
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now