0

I want to run a process right after pb run , I mean after pb running I want the shell commands to be passed to remote box, not sure how to do it.

Step 1) I logon to jump box step 2) get access to dev node after doing pb run on jump box step 3) run my shell commands

all the above steps are in one shell script but after doing pb run the shell doesn't execute child steps it just exists.

how do I pass shell commands to child linux box ?


pbrun -h linuxbox su - bhaluser


Thanks Sri

  • A heredoc is your friend. `pbrun ... <<'EOF'`, then your code to send to the remote system, then an `EOF`. – Charles Duffy Jan 29 '20 at 01:37
  • See https://stackoverflow.com/questions/305035/how-to-use-ssh-to-run-a-shell-script-on-a-remote-machine for the SSH equivalent to this question, which shows the answer I described above among many others. – Charles Duffy Jan 29 '20 at 01:38
  • @CharlesDuffy can you please give an example, so as per my understanding after ssh to jump host from windows using putty while doing pb run to get access to another host from jump host I have to pass my shell commands to pb run ? pbrun ....<<'EOF' | sed 's/a/b/' , something like this ? – sri hari kali charan Tummala Jan 29 '20 at 03:37
  • `pbrun ... <<'EOF'` is the end of one line. Then anything until you have a line that contains only `EOF` with no indentation is sent to the remote system. – Charles Duffy Jan 29 '20 at 03:39
  • There are excellent examples in the answer on the linked question at https://stackoverflow.com/a/3872762/14122 – Charles Duffy Jan 29 '20 at 03:40
  • @CharlesDuffy thank you , I am able to run shell commands which are in Jump box through SSH but I want to run shell command through pb run ...., I will try your example tomorrow , I might need to logon to jump host through ssh and do another ssh to another linux box (Pb run) – sri hari kali charan Tummala Jan 29 '20 at 03:45
  • In general, you can tell ssh itself to use a jumphost directly. `ssh -o 'ProxyJump host1' host2` connects first to host1, and through that to host2. You can also put that in your `~/.ssh/config` file so all connections to host2 *always* silently/automatically go to host1 first. – Charles Duffy Jan 29 '20 at 03:47
  • @CharlesDuffy , tried this below approach pbrun -h linuxbox su - bhaluser << 'EOF' kinit -kt /home/blah.user.keytab blah@BIGBLAH.SOMECOMPANY.COM echo "1" echo "2" echo "3" echo "4" echo "5" EOF , but after doing pbrun usally I jump onto another host but here I am stating in the same pjump host – sri hari kali charan Tummala Jan 29 '20 at 15:04
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/206866/discussion-between-sri-hari-kali-charan-tummala-and-charles-duffy). – sri hari kali charan Tummala Jan 29 '20 at 15:06
  • Newlines, spaces, etc. are critical here. I really need to see actual code exactly as run, and similarly precise output. How about [edit]ing the question? (Changes to substance are frowned on after any answers exist if they could invalidate those answers, but so far this is just comment discussion, so modifications to the question are fair game). – Charles Duffy Jan 29 '20 at 15:44
  • @CharlesDuffy did you mean stack overflow question ? yes I can change it please suggest a name or title for it , this is what I am running (pbrun -h linuxbox su - bhaluser << 'EOF' kinit -kt /home/blah.user.keytab blah@BIGBLAH.SOMECOMPANY.COM echo "1" echo "2" echo "3" echo "4" echo "5" EOF) – sri hari kali charan Tummala Jan 29 '20 at 16:46
  • Honestly, the thing I'm asking you to change is not the title of the question but the code it contains. When you paste your code in a comment, I don't know where the newlines are or what indentation you used, so I don't know if that code is correct; it's effectively useless, and just repeating another comment with the same code again reformatted to remove all its newlines etc makes it no less useless. – Charles Duffy Jan 29 '20 at 16:49
  • ...also, as again previously described, I need to see the *actual output* of that code so I know how you're interpreting the behavior to be wrong. – Charles Duffy Jan 29 '20 at 16:50
  • @CharlesDuffy I sent via chat – sri hari kali charan Tummala Jan 29 '20 at 18:57

0 Answers0