Author Topic: an easy way to remotely execute tasks as they were local  (Read 960 times)

0 Members and 1 Guest are viewing this topic.

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
an easy way to remotely execute tasks as they were local
« on: March 06, 2017, 06:31:14 pm »
so, I happen to have a RISC machine, and gNAT doesn't exist. Therefore I am using the following trick

MachineA: ip 192.168.1.20, RISC workstation
MachineB: ip 192.168.1.24, i686 <-- gGNAT exists!

MachineA and MachineB share a folder-tree through the net (NFS, CIFS, whatever)

Code: [Select]
host_remote="192.168.1.24" # MachineB's IP

echo "step1"
ssh-keygen -t rsa

echo "step2"
if [ ! -f ~/.ssh/id_rsa.pub ]
   then
       echo "failure"
       exit
   fi
ssh $host_remote mkdir -p .ssh

echo "step3"
cat ~/.ssh/id_rsa.pub | ssh $host_remote 'cat >> ~/.ssh/authorized_keys'
(to be executed from the MachineA's console)


Code: [Select]
host_remote="192.168.1.24"

argc="$#"     # how many arg from bash command line ?
app_args=""   # where to store arguments from bash command line
args=("$@")   # args[]={arg0..argC}

here="`pwd`"

argv="cd $here; source /etc/profile; "
for ((i=0;i<argc;i+=1))
    do
       argi="$i"
       argv="$argv ${args[$i]} "
    done

ssh $host_remote $argv

ans="$?"
if [ "$ans" == "0" ]
   then
       answ="success"
   else
       answ="failure"
fi

echo "$answ"
on MachineA, /usr/bin/myrexec  (bash script)






Result, on MachineA

Code: [Select]
remote_ctrl # myrexec gnat list -v

GNATLS 4.3.5
Copyright (C) 1997-2007, Free Software Foundation, Inc.

Source Search Path:
   <Current_Directory>
   /usr/lib/gnat-gcc/i686-pc-linux-gnu/4.3/adainclude/
   /usr/lib/gnat-gcc/i686-pc-linux-gnu/4.3/gcc/i686-pc-linux-gnu/4.3.5/adainclude/


Object Search Path:
   <Current_Directory>
   /usr/lib/gnat-gcc/i686-pc-linux-gnu/4.3/adalib/
   /usr/lib/gnat-gcc/i686-pc-linux-gnu/4.3/gcc/i686-pc-linux-gnu/4.3.5/adalib/


Project Search Path:
   <Current_Directory>
   /usr/lib/gnat/

failure

Code: [Select]
remote_ctrl # myrexec cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Pentium(R) 4 CPU 1.80GHz
stepping : 7
cpu MHz : 1794.360
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pebs bts cid xtpr
bogomips : 3588.72
clflush size : 64
cache_alignment : 128
address sizes : 36 bits physical, 32 bits virtual
power management:

success


Ugly, simple, but it works  :D

 

Offline legacyTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: an easy way to remotely execute tasks as they were local
« Reply #1 on: March 06, 2017, 06:32:41 pm »
both those machines are loaded with linux.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf