Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to kuu to another id inside a shell script

Posted on 2010-09-20
7
Medium Priority
?
2,933 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

636 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