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

automation, pbrun, sh, shell, shell scripts, unix

Thread Tools Search this Thread
# 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
pbrun /bin/su

but for some reason it is not passing thru the

as my code below.

. ~/.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

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
echo $PATH

typing echo $PATH from the external file that opens putty

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.

@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
. ~/.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
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: -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.

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Disk Space Utilization in HTML format working in one environment and not working on the other Harihsun Shell Programming and Scripting 13 08-14-2018 08:45 PM
Working web service call not working with curl abigbear Shell Programming and Scripting 3 08-13-2017 04:02 PM
PHP cronjob not working but manual working fspalero Shell Programming and Scripting 2 08-17-2016 04:50 AM
Nested if not working with /usr/xpg4/bin/awk nes Shell Programming and Scripting 4 05-07-2014 02:08 AM
Nslookup working but ping not working at windows client boby.kumar Red Hat 5 02-28-2014 07:27 AM
Script working when run manually but not in crontab showing path not found raj_saini20 Shell Programming and Scripting 3 07-17-2012 06:47 AM
Script not working in cron but working fine manually jasperux Shell Programming and Scripting 2 07-05-2012 01:37 AM
Putty SSH connection not working herbich1985 Solaris 3 06-20-2012 01:27 AM
/usr/local/bin/expr function not working sdosanjh Shell Programming and Scripting 9 03-15-2012 07:23 AM
Getting issue while running it from cron while manually working fine anuragpgtgerman Shell Programming and Scripting 1 01-23-2012 03:06 PM
Script is not working from cron while working manually anuragpgtgerman Shell Programming and Scripting 3 01-23-2012 02:54 PM
Automating Putty logins sachinpawar2308 Shell Programming and Scripting 2 11-26-2010 03:59 PM
#!/bin/bash has stopped working zorrokan Shell Programming and Scripting 2 09-21-2007 04:02 AM
#/usr/bin/csh -f not working as expected? effigy Shell Programming and Scripting 4 06-05-2006 06:00 PM
/usr/bin/cut not working with largefiles on Solaris 10 wottie Solaris 1 04-04-2006 06:57 PM