Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

There is a Unix environment named sftwrk01, uatwrk01, intwrk01 and some more

I need to check the logs in each environment everyday by login in as below (through pbsu which is a wrapper for pbrun):

$pbsu - sftwrk01  //this helps to login to sftwrk01

and then after login I check the logs. The same process goes for a few more environments like uatwrk01, intwrk01 etc.

Now I tried this:

$pbsu - sftwrk01 && cd var/can/log && ls -lrt

but this did not work because actually the statement cd var/can/log && ls -lrt was being executed after I exited from the sftwrk01 environment by typing exit.

What could be the different possible solutions considering I don't have administrator rights? (i.e I am just one of the users in the home directory.)

If this is not possible without administrator rights then you can mention a way you could do it with having full permission (perhaps you would edit the some .profile file to do that)

**OS Info :**
rcihp145 :/home/msingh2> uname -a
HP-UX rcihp145 B.11.23 U 9000/800 3683851961 unlimited-user license

Other info:

 rcihp145 :/home/msingh2> ls -lrta
 total 7296
-r--r--r--   1 msingh2    users          438 Dec 22  2010 .profile
 drw-------   2 msingh2    users           96 Dec 22  2010 .ssh
-r--r--r--   1 msingh2    users          831 Dec 22  2010 .cshrc
-r--r--r--   1 msingh2    users          347 Dec 22  2010 .exrc
-r--r--r--   1 msingh2    users          333 Dec 22  2010 .login
 -rw-------   1 msingh2    users           56 Dec 23  2010 .sh_history.
-rwxr-xr-x   1 msingh2    users         5451 Dec 23  2010 .dtprofile
 -rw-------   1 msingh2    users      3577932 May 18 05:21 core
drwxr-xr-x  422 root       root         16384 Aug  3 14:27 ..
-rw-------   1 msingh2    users          245 Aug  4 00:41 .Xauthority
-rw-------   1 msingh2    users         1768 Aug  4 00:41 .TTauthority
drwxr-xr-x   4 msingh2    users         8192 Aug  4 00:41 .
 -rw-------   1 msingh2    users        37533 Aug  4 00:41 .ICEauthority
 -rw-------   1 msingh2    users         4064 Aug  4 06:28 .sh_history
 drwxr-xr-x  12 msingh2    users         8192 Aug  4 06:28 .dt
 -rw-------   1 msingh2    users         3462 Aug  5 02:29 .sh_history.msingh2

here is pbsu

share|improve this question
Are you able/willing to modify your pbsu script? –  rozcietrzewiacz Aug 5 '11 at 11:25
pbrun is actually designed to do what you want. The problem is that your pbsu script wraps it in an inconvenient way. –  mattdm Aug 5 '11 at 12:18
thanks but I dont want to modify that(pbsu) either –  munish Aug 5 '11 at 12:38
Unfortunately, the way that pbsu script is written, you would have to do either (modify .profile or pbsu). –  rozcietrzewiacz Aug 5 '11 at 12:48
Soory for trouble people... I seem to be putting a lot of restriction to do this... but even I have very restricted authorisation while working... so I wanted to find some unique way to do my work faster and easier way without logging into each account and then logging out and then logging in again to anohter one just to do some simple checks...(annoying)...!! I thought I could atomate it –  munish Aug 5 '11 at 12:50
show 4 more comments

1 Answer

up vote 4 down vote accepted

I do not know if the server shell you are logging into is the original Korn Shell, but if so, you can modify the end of pbsu script so that

   [ -n "$REMOTEHOST" ] && /usr/local/bin/pbrun -h $REMOTEHOST -u $USERNAME /usr/local/bin/pbksh $LOGIN_SWITCH
   [ -n "$REMOTEHOST" ] || /usr/local/bin/pbrun -b -u $USERNAME /usr/local/bin/pbksh $LOGIN_SWITCH


   [ -n "$REMOTEHOST" ] && /usr/local/bin/pbrun -h $REMOTEHOST -u $USERNAME /usr/local/bin/pbksh $LOGIN_SWITCH ${@:2}
   [ -n "$REMOTEHOST" ] || /usr/local/bin/pbrun -b -u $USERNAME /usr/local/bin/pbksh $LOGIN_SWITCH ${@:2}

Then you'd be able to just send commands to the server without logging into the shell, using

pbsu - sftwrk01 -c "your commands here"

(Mind the quotes!) So, for your example, it would be

pbsu - sftwrk01 -c "ls -lrt var/can/log"

(Notice, by the way, that you don't need to change to some directory to list its contents - just give the name of that directory to the ls command, as shown above.)

share|improve this answer
+1 for the info @rozcietrzewiacz I guess this is the only possible way(apart from editing the .profile) as told by you.+1 to the answer also...thanks a lot :) –  munish Aug 5 '11 at 12:57
No problem :) And thanks for accepting in spite of all! –  rozcietrzewiacz Aug 5 '11 at 13:15
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.