Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Digital Archaeology » Computer Arcana » Commodore » Commodore 8-bit » Using tcpser on a Pi for telnet gateway to C64?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347274 is a reply to message #347269] Wed, 28 June 2017 10:49 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Dropnine

On Wednesday, June 28, 2017 at 7:27:01 AM UTC-6, 6502en...@gmail.com wrote:

.....
> I saw tcpser down in the list.
> I got the 1.
> All is running now.
>
> I don't know if the script is working. I named it startSerial, made everything as you said - but if I type "./startSerial" I get the result "unknown error in line 8" ...?
>
> Now I will see if tcpser stops again or if it is running well ...
>
> Thanks a lot for all of your help!

Line 8 has an error in it. If the cron job is running, it will never restart the tcpser application because it relies on the script to start it :( Check line 8 and make sure it's proper--there's a mistake of some kind on that line.
Using tcpser on a Pi for telnet gateway to C64? [message #347275 is a reply to message #347269] Tue, 27 June 2017 19:10 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: nospam.mark.lewis

On 2017 Jun 28 06:26:58, you wrote to All:

en> I don't know if the script is working. I named it startSerial, made
en> everything as you said - but if I type "./startSerial" I get the result
en> "unknown error in line 8" ...?

the script cannot work if it is erroring out... we cannot tell what the error
is without seeing the script... you know what to do next, right? ;)

)\/(ark

Always Mount a Scratch Monkey
Do you manage your own servers? If you are not running an IDS/IPS yer doin' it
wrong...
.... Timing has an awful lot to do with the outcome of a rain dance.
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347276 is a reply to message #347275] Wed, 28 June 2017 12:19 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: 6502enhanced

:-) ... I know ... here are the pics:

The script:

https://s18.postimg.org/xki8l2byx/Full_Size_Render.jpg

Screen after ./startSerial:

(correct translation is: Syntax Error: unexpected end of file

https://s13.postimg.org/is0zi1yzb/IMG_3763.jpg
Using tcpser on a Pi for telnet gateway to C64? [message #347286 is a reply to message #347276] Tue, 27 June 2017 20:44 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: nospam.mark.lewis

On 2017 Jun 28 09:19:44, you wrote to All:

en> :-) ... I know ... here are the pics:

you do realize that pasting the actual text into a message would have been
smaller and easier, right? ;)

en> (correct translation is: Syntax Error: unexpected end of file

yeah, "if" statements end with "fi"... you don't have one...


if [blah blah ] ; then
do something
fi



)\/(ark

Always Mount a Scratch Monkey
Do you manage your own servers? If you are not running an IDS/IPS yer doin' it
wrong...
.... I plead not guilty by reason of computer-induced insanity.
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347287 is a reply to message #347286] Wed, 28 June 2017 13:50 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: 6502enhanced

Thanks a lot!

It seems that all is now working!

I've put the "fi" in and then at the prompt I typed "./startSerial" - and then tcpser started. So I hope that CRON Table is now also working and will start the startSerial script if tcpser stops again.
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347310 is a reply to message #347287] Wed, 28 June 2017 17:08 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Dropnine

On Wednesday, June 28, 2017 at 11:50:54 AM UTC-6, 6502en...@gmail.com wrote:
> Thanks a lot!
>
> It seems that all is now working!
>
> I've put the "fi" in and then at the prompt I typed "./startSerial" - and then tcpser started. So I hope that CRON Table is now also working and will start the startSerial script if tcpser stops again.
.....

Interesting. The fi on mine is only required when there's an else included with the if/then...

To check if the cron is working, check the log or kill the tcpser service or just restart the pi and check to see if it loads up.

Cheers,
c
Using tcpser on a Pi for telnet gateway to C64? [message #347327 is a reply to message #347269] Wed, 28 June 2017 18:44 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: nospam.Janne.Johansson

On 2017-06-28 05:26, 6502enhanced@gmail.com : All wrote:
> Am Montag, 26. Juni 2017 20:45:48 UTC+2 schrieb Dropnine:

> OK, I've done the following:
>
> - wrote "tcpser -s 2400 -d /dev/ttyUSB0 -p 6502 -ts &"
> - then ps -A
> - and ps -x | grep -v grep |grep -c "tcpser"
>

I didn't want to turn this into a "my oneliner is better than yours",
but unix shells makes this rather simple:

pgrep tcpser || tcpser -s 2400 -d /dev/ttyUSB0 -p 6502 -ts &

which basically means,

"if tcpser is not found among the list of running programs, run it again"

or even more verbose explanation:

pgrep <name of program>
will return an "ok" exit code if found, and error code if not.

the || double-pipe means "if error, run stuff behind ||, else skip"
which is the opposite of the more common && operator which means
"run the stuff behind && only if previous command went well" mostly
used to make sure each step of a long series of commands worked and not
continue otherwise.

So, all in all, pgrep for the program, if not found, pgrep will signal
that it failed its mission to find tcpser in the process list, and runs
the command after, which incidentally is the full tcpser command again.

Since pgrep is rather cheap to execute, you could just run this as often
as you like, even in a loop like this:

while sleep 1
do
pgrep tcpser || tcpser ...
done

If this is in rc.local and you want that script to exit, use shell ()
feature (called 'subshell') and place that one into the backgroup with a
single &.

( while sleep 1
do
pgrep ...|| ..
done
) &

and you have yourself a daemon style script that checks for tcpser every
second (every sleep X interval) and restarts it asap if its gone.
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347330 is a reply to message #347327] Thu, 29 June 2017 09:19 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Dropnine

On Thursday, June 29, 2017 at 2:11:07 AM UTC-6, Janne Johansson wrote:
>
> pgrep tcpser || tcpser -s 2400 -d /dev/ttyUSB0 -p 6502 -ts &
>
> which basically means,
>
> "if tcpser is not found among the list of running programs, run it again"
>

That rocks too. "100 ways to skin a cat" as they say. I still personally prefer such things to be a service and let OS all takes care of itself without the hacking of the rc. But it's fun hacking around with the stuff, that's for sure. There's probably another 10 ways out there to do it. If they're centralized here then they're easy to find all in one spot :) If there's other ways, share 'em.

Cheers,
c
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347345 is a reply to message #347330] Thu, 29 June 2017 13:43 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: 6502enhanced

Great! I typed that also in - why not a second door to make tcpser run if it stops.
Thanks a lot!
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347507 is a reply to message #347345] Wed, 05 July 2017 09:51 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: 6502enhanced

OK - the problem is not solved so far ...

Tcpser run now for a few days well.

Then it stopped again.

I typed:ps x |grep -v grep |grep -c "tcpser"

The result was: 0

Tcpser was also not started by CRON after a few minutes ...

Then I typed: ./startSerial

Tcpser started. At the moment it is running, but I don't know why it is not startet by CRON automatically, because the script seems to work good...?
Using tcpser on a Pi for telnet gateway to C64? [message #347508 is a reply to message #347507] Tue, 04 July 2017 18:54 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: nospam.mark.lewis

On 2017 Jul 05 06:51:52, you wrote to All:

en> Tcpser was also not started by CRON after a few minutes ...

en> Then I typed: ./startSerial

en> Tcpser started. At the moment it is running, but I don't know why it is
not
en> startet by CRON automatically, because the script seems to work good...?

where, exactly, is your script?
what, exactly, is your cron entry?

)\/(ark

Always Mount a Scratch Monkey
Do you manage your own servers? If you are not running an IDS/IPS yer doin' it
wrong...
.... The four seasons: onions, celery, bell pepper, and garlic.
Using tcpser on a Pi for telnet gateway to C64? [message #347509 is a reply to message #347508] Wed, 05 July 2017 02:15 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: nospam.Janne.Johansson

On 2017-07-05 16:54, mark lewis : 6502enhanced@gmail.com wrote:

> en> Tcpser was also not started by CRON after a few minutes ...
>
> en> Then I typed: ./startSerial
>
> en> Tcpser started. At the moment it is running, but I don't know why
> it is not
> en> startet by CRON automatically, because the script seems to work
> good...?
>
> where, exactly, is your script?
> what, exactly, is your cron entry?

A common "problem" is that cron is run with a conservative PATH env.
variable, so it will not find the same commands as you do when you have
logged in interactively, so giving full path to stuff in /usr/local or
placed otherwise in "strange" locations (basically anything except
/bin,/sbin,/usr/bin,/usr/sbin) is more or less a must for cron jobs.
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347516 is a reply to message #347509] Wed, 05 July 2017 13:23 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: 6502enhanced

"Where, exactly, is your script?"

- well, I don't know. How can I find that out?

"What, exactly, is your cron entry?"

- At the bash I typed: "crontab -e"
- then I selected "nano" as editor
- then I typed into the last line:" */1 * * * * /home/pi/startSerial"
- then I pressed:"<CTRL-X>"
- then "Y"
- then "Return"

--------------------
"so giving full path to stuff in /usr/local or
placed otherwise in "strange" locations (basically anything except
/bin,/sbin,/usr/bin,/usr/sbin) is more or less a must for cron jobs."

You mean it should be saved in /usr/local ? How can I save it there? As described above, nano offers just to save it with "<CTRL-X>".

Thanks for your help!
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347536 is a reply to message #347516] Wed, 05 July 2017 15:35 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Dropnine

On Wednesday, July 5, 2017 at 11:23:22 AM UTC-6, 6502en...@gmail.com wrote:
> "Where, exactly, is your script?"
>
> - well, I don't know. How can I find that out?
>
> "What, exactly, is your cron entry?"
>
> - At the bash I typed: "crontab -e"
> - then I selected "nano" as editor
> - then I typed into the last line:" */1 * * * * /home/pi/startSerial"
> - then I pressed:"<CTRL-X>"
> - then "Y"
> - then "Return"
>
> --------------------
> "so giving full path to stuff in /usr/local or
> placed otherwise in "strange" locations (basically anything except
> /bin,/sbin,/usr/bin,/usr/sbin) is more or less a must for cron jobs."
>
> You mean it should be saved in /usr/local ? How can I save it there? As described above, nano offers just to save it with "<CTRL-X>".
>
> Thanks for your help!

The /home/pi/startSerial you've entered explicitly tells cron to run the startSerial script in the /home/pi directory. there is nothing else it will try or guess. That script obviously works fine as when you run it manually, it works. So your attention should be on the CRON job. That line may not be proper and you might want to copy the line from the text and then copy it into the editor then save it the file. That is a guess at this point. Ther eis no need to copy that script anywhere else.

CRON does have a log file, but you need to turn it on. the log file is placed in the /var/logs directory under the name cron. you can inspect that file and then you will know what the issue is. The info to turn on the cron log is at the end of the document.

*When running against a timer, it is best to use CRON, always, not an endless loop in a script -- that is very bad practice as scripts are meant to run and then stop and then they are envoked again when needed.

* I will make an image of my pi's sd and you can just write that to your flash card and just get it done. I am teaching this evenning so I might not be able to get to it until tomorrow if that's OK. It will be located in the shared folder and publically avalaible.

Best of luck :)
Cheers,
c
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347541 is a reply to message #347507] Wed, 05 July 2017 17:29 Go to previous messageGo to next message
Andreas Kohlbach is currently offline  Andreas Kohlbach
Messages: 1456
Registered: December 2011
Karma: 0
Senior Member
On Wed, 5 Jul 2017 06:51:53 -0700 (PDT), 6502enhanced@gmail.com wrote:
>
> OK - the problem is not solved so far ...
>
> Tcpser run now for a few days well.
>
> Then it stopped again.
>
> I typed:ps x |grep -v grep |grep -c "tcpser"
>
> The result was: 0

May be it "forked" into something else?

> Tcpser was also not started by CRON after a few minutes ...

Do other jobs start in this cron table? Might be a typo or wrong
permission in it?

> Then I typed: ./startSerial
>
> Tcpser started. At the moment it is running, but I don't know why it
> is not startet by CRON automatically, because the script seems to work
> good...?

Doesn't tcpser listen on a port? If it was still running (under a
different name, why ever that may have happened) the port already in use.

May be next time it seems to have stopped also test if the port it runs
on is still used. Something like

lsof -i :1234 (< replace by actual port)
--
Andreas
You know you are a redneck if
you own a homemade fur coat.
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347589 is a reply to message #340094] Thu, 06 July 2017 04:29 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: 6502enhanced

"I will make an image of my pi's sd and you can just write that to your flash card and just get it done. I am teaching this evenning so I might not be able to get to it until tomorrow if that's OK. It will be located in the shared folder and publically avalaible"

That would be great! Thanks a lot! (Where is the shared folder?)

"Do other jobs start in this cron table? Might be a typo or wrong
permission in it?"

So far as I see there are no other jobs in that cron table.
I will compare Dropnine's with mine or write that to my card.
Re: Using tcpse [message #347907 is a reply to message #346091] Sun, 09 July 2017 22:17 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Dropnine

I've included an image for the Pi that will start it on boot and monitor tcpser; in case of a crash it will restart the tcpser application.

You can retrieve the image and documentation here:

https://drive.google.com/drive/folders/0B7Y4Lsah28nCem54WnBW YkZ5LTQ

Cheers,
c
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347908 is a reply to message #347589] Sun, 09 July 2017 22:19 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Dropnine

Sorry for the wait, building a garage and teaching is taking quite a slice of my time.

I've included an image for the Pi that will start it on boot and monitor tcpser; in case of a crash it will restart the tcpser application.

You can retrieve the image and documentation here:

https://drive.google.com/drive/folders/0B7Y4Lsah28nCem54WnBW YkZ5LTQ

I've tested the image and it works fine. I took it from my B+ 2011 Pi.

Cheers,
c
Re: Using tcpser on a Pi for telnet gateway to C64? [message #347920 is a reply to message #347908] Mon, 10 July 2017 06:38 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: 6502enhanced

Thanks a lot! I'll try that.
Re: Using tcpser on a Pi for telnet gateway to C64? [message #348423 is a reply to message #347920] Sat, 15 July 2017 00:10 Go to previous message
Anonymous
Karma:
Originally posted by: Dropnine

On Monday, 10 July 2017 04:38:02 UTC-6, 6502en...@gmail.com wrote:
> Thanks a lot! I'll try that.

A new image is available. It contains commands to set the serial and a possible wifi connection, as well. setSerial will define the tcp to serial bridge and restart tcpser with the new values. setWifi will setup a WPA encrypted connection if you happen to have a wifi or a USB Wifi on your Pi. If the commands are issued without parameters, they will display a how to use.

It's still not completely fool proof, but it will help those who do not want to edit or possibly messing up their image.

Cheers,
c
Pages (2): [ «    1  2]  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: FREE: Commodore Stuff
Next Topic: Official FAQ comp.binaries.cbm (semimonthly posting)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Mar 29 11:23:58 EDT 2024

Total time taken to generate the page: 0.05170 seconds