I'm trying to SSH from a mac osx machine to a solaris based machine and pass some commands but I'm not sure the best way to do it and am running into all sorts of issues using the different methods I've found online. Right now the closest thing I have to working is:
fraudcheck.sh
#!/bin/sh
#
SUPNODE="X.X.X.X"
ssh -i /Users/jessebutryn/.ssh/Jesse_id_rsa root@$SUPNODE < /Users/jessebutryn/Documents/scripts/incomplete/fraudcommands.sh
fraudcommands.sh
#!/bin/sh
#
source /root/toolbox/toolbox
jbutryn
fraud 1
When I run these commands manually the output is as follows:
joyentmac2252:~ jessebutryn$ ssh [email protected]
[root@sup-jpc-west1 ~]# source /root/toolbox/toolbox
Enter your JPC Headnode username: jbutryn
Toolbox - Version 4.4.6 - It's Wednesday, this must be Devon (20161116)
---- Recent Changes ----
Replaced sdc-ldap/ufds with OpenLDAP client
vm/vmi now shows Swap
Moved creds to environment
Added random element to disabler string
fraud() speed up
Added over() for PD overrides
Added RAM to vms_by_pkg / fraud
Added dates to cust()
Big speed up for cust_vms(). You are welcome.
------------------------
[root@sup-jpc-west1 ~]# fraud 1
2017-06-29|2017-06-30
DC ALIAS UUID RAM BILLING_ID OWNER CREATED
sw_1 SRADB02PRJOY f70b0642-020c-cd72-d644-e0453ccd0e56 65536 14bc8e86-d0f8-11e5-a148-b39af8e5cb7b bc1e2a34-e6fd-c421-d362-aeccb09eb9a4 2017-06-30T20:29:36.853Z
...
However when I run the script it gives the following output:
joyentmac2252:~ jessebutryn$ ~/Documents/scripts/incomplete/fraudcheck.sh
Pseudo-terminal will not be allocated because stdin is not a terminal.
Toolbox - Version 4.4.6 - It's Wednesday, this must be Devon (20161116)
---- Recent Changes ----
Replaced sdc-ldap/ufds with OpenLDAP client
vm/vmi now shows Swap
Moved creds to environment
Added random element to disabler string
fraud() speed up
Added over() for PD overrides
Added RAM to vms_by_pkg / fraud
Added dates to cust()
Big speed up for cust_vms(). You are welcome.
------------------------
/root/toolbox/toolbox: line 1888: [: =: unary operator expected
2017-06-29|2017-06-30
DC ALIAS UUID RAM BILLING_ID OWNER CREATED
Below is line 1888 in the toolbox script and I'm not even sure what it's purpose is but I know I don't match that user:
[root@sup-jpc-west1 ~]# sed '1888!d' sup-toolbox/toolbox
if [ $(who am i | /usr/bin/cut -d' ' -f 1) = "some_user" ]; then
I've tried all sorts of solutions for passing the commands through including:
echo "jbutryn" | ssh -i ...
ssh -i ... "
jbutryn
fraud 1
"
I've tried to echo and read the commands in the fraudcommands script. I'm fairly new to all of this so any help is appreciated. Thanks!