I am developing a python application for a remote system which has a device connected via a serial port.
At the moment my workflow looks like this
- write code locally
- commit to git
- git push
- change to terminal window holding ssh session
- git pull
- run python code
This is kind of awkward and I want to speed things up and increase my work efficiency using some scripts
I have written two scripts, one for local and one for remote
My local script looks like this
#!/bin/bash
# do git commit
if [ "$#" -eq 3 ]
then
if [ "$1" == "-m" ]
then
git commit -am "$2"
else
echo "syntax error, -m expected as argument 1"
exit
fi
else
git commit -am "execute.sh script"
fi
# do git push
git push
# login to ssh and execute script
ssh <user>@<ip> 'bash -s' < remote-execute.sh
My remote-execute.sh
looks like this
#!/bin/bash
# cd
cd <dir>
# do git pull
git pull
# run python
python3 main.py
My python code uses Python Curses (ncurses) for GUI interaction
When I run these scripts, I encounter the error
Traceback (most recent call last):
File "Monitor.py", line 1140, in <module>
curses.wrapper(main)
File "/usr/lib/python3.5/curses/__init__.py", line 73, in wrapper
stdscr = initscr()
File "/usr/lib/python3.5/curses/__init__.py", line 30, in initscr
fd=_sys.__stdout__.fileno())
_curses.error: setupterm: could not find terminal
This must be due to how I am using ssh with the "-s" switch to execute the remote script.
Is there a way to fix this? It seems like some kind of terminal stuff isn't being forwarded properly? I can't say anything more than this because it's a bit beyond my knowledge.