Automating pbrun /bin/su not working, whenever manually it is working using putty


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automating pbrun /bin/su not working, whenever manually it is working using putty
# 1  
Old 11-30-2015
Automating pbrun /bin/su not working, whenever manually it is working using putty

I am trying to automate a script where I need to use
Code:
pbrun /bin/su

but for some reason it is not passing thru the
Code:
pbrun

as my code below.

Code:
. ~/.bash_profile
pbrun /bin/su - content
c h 1
hpsvn up file path

I am executing this from an external .sh file that is pointing to this scripts file but it is not running, if I do it in putty manually mode it works but if I run it from automate script it is not working, There is a difference between the
Code:
$PATH

but I don't know what relation does that has with the problem.
# 2  
Old 11-30-2015
What do you mean by "automate"? Starting/running scripts via cron? Then you need to explicitly define the PATH variable so all the needed paths are available.
Any error msgs, by the way?
# 3  
Old 11-30-2015
By automating, I am referring to instead of typing manually, everything will be read from an external file, I have an .sh file that connects to the server with the usr and password and read the scripts from an .txt file that I have.

Once my putty window prompts once I start this automation scripts, it just freeze after executing pbrun /bin/su without continue reading my commands script or even allowing to type other command manually, even it isn't showing any errors on the window.

How can I define the $PATH from my external script? the difference between my paths are

manually opening putty and typing
Code:
echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/axphome/jjacome/bin:/amex/bin:/amex/bin/GenSync

typing echo $PATH from the external file that opens putty
Code:
/usr/local/bin:/bin:/usr/bin:/axphome/jjacome/bin:/amex/bin:/amex/bin/GenSync

Does this difference is the error of why it is not proceeding?

Last edited by rbatte1; 12-08-2015 at 07:58 AM.. Reason: Added CODE & ICODE tags
# 4  
Old 11-30-2015
Not clear. What's an external file? Where is it located? Where are those .sh and .txt files located? Please post mode details.
# 5  
Old 11-30-2015
So I have a .bat file that will connect to putty and execute the scripts in the path Documents\Heroes\e1_scripts.txt.

Code:
ssh.cmd
@echo on
cd C:\Users\jjaco23\Desktop
putty.exe -ssh ipaddress -l user -pw password -m C:\Users\jjaco23\Documents\Heroes\e1_scripts.txt

In the file e1_scripts.txt
Code:
. ~/.bash_profile
pbrun /bin/su - content <----Getting freeze in here
c h 1
hpsvn up file.html

I am just executing svn commands that I want instead of doing it manually to be executed from this external file. If I type manually in putty all this commands it works fine but whenever I execute from this .bat file and reading the scripts file, it is getting stop in the line
Code:
pbrun /bin/su - content

without proceeding with the next line.

I researched a little bit by looking that the $PATH variable if I run it manually opening putty is different than being executed from this external .bat file.

Hopefully I was more clear this time.
# 6  
Old 11-30-2015
From the puttydocumentation:
Quote:
3.8.3.6 -m: read a remote command or script from a file

The -m option performs a similar function to the ‘Remote command’ box in the SSH panel of the PuTTY configuration box (see section 4.18.1). However, the -m option expects to be given a local file name, and it will read a command from that file.
With some servers (particularly Unix systems), you can even put multiple lines in this file and execute more than one command in sequence, or a whole shell script; but this is arguably an abuse, and cannot be expected to work on all servers. In particular, it is known not to work with certain ‘embedded’ servers, such as Cisco routers.

Did you consider using plink (from the putty family)?
# 7  
Old 12-01-2015
Can't due software approval restrictions.

So as I am understanding the -m is not allowing to proceed due my server, but why I am able to run it manually in putty but not from the .bat file.

---------- Post updated 12-01-15 at 09:30 AM ---------- Previous update was 11-30-15 at 12:16 PM ----------

My issue is similar to this other thread

"I have a script, which pbruns into another account.
I want to pbrun run into that account, and continue running all the commands in my script.
But instead, it pbruns into the account, and just gives me a shell prompt.. and stops there.
Only once i exit that shell prompt.. does it continue running the rest of the sciprt."

No further solutions that works for the moment.

After the pbrun is executed it is getting stuck without proceeding.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nested if not working with /usr/xpg4/bin/awk

Hi, I am trying to do if inside the If in /usr/xpg4/bin/awk. But I am getting below error : /usr/xpg4/bin/awk -v a="${THREADIDARR }" 'BEGIN {FS="|"; n=split(a,b," "); for(i=1; i<=n; i++) c]=1;} length($3) == 0{ftag == 1{{print}}; length($3) != 0{$3 in c{ftag=1;print;} !$3 in c{ftag=0;}}'... (4 Replies)
Discussion started by: nes
4 Replies

2. Shell Programming and Scripting

Script working when run manually but not in crontab showing path not found

i have a script running using variable defined in .profile when i run that script manually its working but when i run the same script through cron its giving path not found I had defined path in .profile (3 Replies)
Discussion started by: raj_saini20
3 Replies

3. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

4. Solaris

Putty SSH connection not working

I am trying to connect to a solaris server using putty from a indows client. SSH connection is not working. The terminal indow just gives an error message "Network error:Connection refused". I verified SSHD and its running correctly! #svcs -p ssh STATE STIME FMRI online 17:54:44... (3 Replies)
Discussion started by: herbich1985
3 Replies

5. Shell Programming and Scripting

/usr/local/bin/expr function not working

Legends, I am not able to set "expr" function in ksh script. Below is the sample code i used, and output is as "Syntax error" Please help me to come out of it. OUTPUT (9 Replies)
Discussion started by: sdosanjh
9 Replies

6. Shell Programming and Scripting

Getting issue while running it from cron while manually working fine

Hello, I am working one one script where I am using the below code which is using to connect with MKS client when I run my script manually it works effiecently i.e. it connects with MKS client but when I run it from CRON it doesn't connect. 1)Can some one tell when it is running from cron... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

7. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

8. Shell Programming and Scripting

#!/bin/bash has stopped working

Hi I'm writing a script and I've put #!/bin/bash as the first line so that I can just type my scripts name 'whodate' at PS1 instead of ./whodate. This has suddenly stopped working for me. It used to be the case that I could start a script with #!/bin/bash and it would work, but for this script... (2 Replies)
Discussion started by: zorrokan
2 Replies

9. Shell Programming and Scripting

#/usr/bin/csh -f not working as expected?

Hey everyone, A coworker of mine has written a csh script that starts with #!/usr/bin/csh -f. It's my understanding that the -f should skip the .cshrc and .login files, but here's the problem: In the script "line" is used, and I happen to have a "line" in my ~/bin. When the script is ran my... (4 Replies)
Discussion started by: effigy
4 Replies

10. Solaris

/usr/bin/cut not working with largefiles on Solaris 10

I have a person running a perl script that is parsing > 2G log files and pipes to cut -d " " -f 1,6,7,8... The script itself is in a nfs mounted home directory. It runs fine when started from a solaris 8 box but fails after about 400 lines when started from the solaris 10 box. The solaris... (1 Reply)
Discussion started by: wottie
1 Replies
Login or Register to Ask a Question