Pass Multiple Commands and Open Multiple Xterms via PSS


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Pass Multiple Commands and Open Multiple Xterms via PSS
# 1  
Old 08-01-2014
Pass Multiple Commands and Open Multiple Xterms via PSS

Hello,

I'm attempting to open multiple xterms and run a command as an SAP user via sudo using PSSH. So far, I'm able to run PSSH to a file of servers with no check for keys, open every xterm in to the servers in the file list, and SUDO to the SAP(ADM) user, but it won't do anything else afterwards.
I've tried many combinations and I'm not sure if my options for the pssh nor the xterm options are set correctly....Here is what I have now..
Code:
pssh -i -h ectsrv -A -O StrictHostKeyChecking=no "export DISPLAY=IP address:0.0;  xterm -hold -e "sudo /path/sap_sudo.sh" "

I've tried many combinations..with and without quotes of single and double:
Code:
xterm -e sudo "cmd1;cmd2;ls;bash"
xterm -e sudo "cmd1 && cmd2"
xterm -e sudo "cmd1;cmd2; ksh"
xterm -e sudo "-tt" "cmd1;cmd2;ls;bash"

Completely stuck at SIDADM> in new windows, but it won't run commands afer...please assist!
Thanks for any feedback
Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, output, and code segments.

Last edited by Don Cragun; 08-01-2014 at 05:57 PM.. Reason: Add CODE tags.
# 2  
Old 08-01-2014
No combination of quotes and semicolons is going to help when your shell code isn't being fed into a shell. xterm is not a shell, and won't understand cmd1;cmd2;...

Also, when you ssh through, your local shell may strip off the outer layer of quotes, turning it into xterm -e cmd1 ; cmd2 ; ls ; bash which is probably not what you want -- it will wait for xterm to quit before running the rest, outside!

To have xterm run a shell, tell xterm to run a shell. You can feed a string into most Bourne shells with the -c option.

Code:
xterm -e sudo bash -c "'cmd1;cmd2;ls;exec bash'"

I'm not 100% sure whether you need the extra ' ' when you run it with SAP or not. It depends whether your code gets fed into an actual shell, or just a dumb splitter. A dumb splitter might need exec\ bash to not split upon the space, even though its inside quotes.

...the 'exec bash' at the end should drop it to an interactive prompt. If it's not doing a good enough job of loading your profile, try exec bash -l.

Last edited by Corona688; 08-01-2014 at 05:56 PM..
# 3  
Old 08-01-2014
How are you running sisadm? Give an example. I am not familiar with sisadm; however, perhaps you are hitting it in an interactive mode and there is a way to run it by redirecting it's standard input, or by a command line argument that points to a script containing sisadm commands.
# 4  
Old 08-01-2014
As I understand it SAP is about as noninteractive as it gets, hence the desperate attempts to kludge a real, actual interactive shell into its one-way thinking.
# 5  
Old 08-01-2014
Hey Thanks for all of your quick replies. I appreciate that!!

I'm able to sudo to my sap(adm) user via the sudo /path/sap_sudo.sh. So that part works well with all xterm windows at my user prompt
SAPADM>
Now if I can run command any unix or SAP command, which I can manually from these windows, such as ls -lrt, pwd, or R3trans -d then that would be crazy good. Imagine that and seeing the output on all systems in the different windows at the same time. :-) That's my goal.

I'll give
Code:
xterm -e sudo bash -c "'cmd1;cmd2;ls;exec bash'"

a try and then the exec bash -l .....

Last edited by Don Cragun; 08-01-2014 at 06:59 PM.. Reason: Add CODE and ICODE tags.
# 6  
Old 08-05-2014
Code:
xterm -e sudo bash -c "'cmd1;cmd2;ls;exec bash'"

I've also tried
Code:
pssh -i -h ectsrv -A -O StrictHostKeyChecking=no "export DISPLAY=IP address:0.0; xterm -hold bash -e "sudo /path/sap_sudo.sh 'ls;whoami;bash -l" "

Multiple times in different ways...nothing.

However, I did try this
Code:
pssh -i -v -h ectsrv -A -O StrictHostKeyChecking=no "export DISPLAY=IP.IP.IP:0.0; xterm -hold -e ls; sudo /path/sap_sudo.sh ""

and the ls command worked, but as my userid and not the SID and the title of the XTERM was labled "ls"....

Unfortunately, it will sudo, but won't LS when the ls command is at the end per the earlier command...

Please assist. Thanks for any replies..

Last edited by Franklin52; 08-07-2014 at 03:12 AM.. Reason: Please use code tags
# 7  
Old 08-05-2014
Well of course it won't. It has to be like this:

Code:
... xterm -e command ...

...because if you don't put the commands into xterm, they're not going to be in xterm.

Try just pssh -i -h ectsrv -A -O StrictHostKeyChecking=no "export DISPLAY=IP address:0.0; xterm -e bash" to see if you can at least get a terminal prompt. If you can get a terminal prompt, try and build from there.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with bash script to open arbitrary # of independent xterms

I run multiple processes that require I pop open multiple xterms, how can I do this in a script and have each xterm colored differently and labled for the servername they represent, for example if I do ssh username@serverip I would need the xterm to be opened with that servername at the top and... (3 Replies)
Discussion started by: smth333
3 Replies

2. Shell Programming and Scripting

Is is possible to pass multiple entries in PS3 select ?

PS3="Enter corresponding number and hit enter:" select DIR in `cat mylist` QUIT do if then echo "INVALID INPUT" else if ; then my commands ..... else break fi fi REPLY='' done The above will return something like below : Select from the list of... (4 Replies)
Discussion started by: ningy
4 Replies

3. Shell Programming and Scripting

How to automatically pass 'multiple' user inputs

Hi Everyone, 1) I really cannot figure out how to pass multiple user inputs in a script. really need your help re this. below is the script. ----------- #!/bin/sh # script name: ask.sh echo "Enter name: \c" read NAME echo "Your name is $NAME\n" echo "Enter age: \c" read AGE echo... (5 Replies)
Discussion started by: mcoblefias
5 Replies

4. UNIX for Dummies Questions & Answers

multiple text edits inone pass

File_1 looks like: bunch of text Untitled Placemark bunch of text bunch of text Untitled Placemark bunch of text bunch of text Untitled Placemark bunch of text File_2 looks like: Title_001 Title_002 Title_003 First: I need to replace the 1st occurence of "Untitled Placemark"... (2 Replies)
Discussion started by: kenneth.mcbride
2 Replies

5. Shell Programming and Scripting

perform 3 awk commands to multiple files in multiple directories

Hi, I have a directory /home/datasets/ which contains a bunch (720) of subdirectories called hour_1/ hour_2/ etc..etc.. in each of these there is a single text file called (hour_1.txt in hour_1/ , hour_2.txt for hour_2/ etc..etc..) and i would like to do some text processing in them. Each of... (20 Replies)
Discussion started by: amarn
20 Replies

6. Programming

Control multiple program instances - open multiple files problem

Hello. This shouldn't be an unusual problem, but I cannot find anything about it at google or at other search machine. So, I've made an application using C++ and QtCreator. I 've made a new mime type for application's project files. My system (ubuntu 10.10), when I right click a file and I... (3 Replies)
Discussion started by: hakermania
3 Replies

7. Solaris

Help with executing multiple remote commands after multiple hops

Hi SSHers, I have embedded this below code in my shell script.. /usr/bin/ssh -t $USER@$SERVER1 /usr/bin/ssh $USER2@S$SERVER2 echo uptime:`/opt/OV/bin/snmpget -r 0 -t 60 $nodeName system.3.0 | cut -d: -f3-5` SSH to both these servers are public-key authenticated, so things run... (13 Replies)
Discussion started by: LinuxUser2008
13 Replies

8. Shell Programming and Scripting

Commands to multiple xterms

Hi, I need some help with sending commands to multiple xterms. What I do is ssh -Y to a remote box, and then open up 4 shells (csh) and on each one I run a different program in sequence -- one of them has 2, the first of which goes into the background and after you hit "enter" or "return" you get... (0 Replies)
Discussion started by: rmoriarty
0 Replies

9. Shell Programming and Scripting

How do we pass multiple arguments into awk

How do we pass multiple arguments into awk : name=john age=12 now i have to pass both age and name into awk.. how to do it? like : awk -v var=... (4 Replies)
Discussion started by: abhinav192
4 Replies

10. UNIX Desktop Questions & Answers

resize multiple xclients (xterms) on command line or programmatically?

Is there a way to resize x clients after they're started either on the command line or programmatically? I'm using Cygwin and typically start my root window, wm, and four xterms. By the end of the day they're all over the place with different sizes. I'd like to be able to enter a single command... (0 Replies)
Discussion started by: gctaylor
0 Replies
Login or Register to Ask a Question