Solved

How to kuu to another id inside a shell script

Posted on 2010-09-20
7
2,854 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Annoying "thing" blocks my view 4 100
Problem to event 3 96
VBA Shell can't Find Word document 11 92
"Black Box" Testing of Control System Software 2 51
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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.

772 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