Go to advanced search

by tpyo kingg
Wed Feb 20, 2019 6:28 am
Forum: Networking and servers
Topic: autoSSH
Replies: 4
Views: 527

Re: autoSSH

Ok. A while loop for the reverse tunnel works to reconnect, but you may want to adjust the ServerAliveCountMax and ServerAliveInterval options. those plus IdentityFile and IdentitiesOnly can then go in ~/.ssh/config on that RPi once you have the values set, or you can leave them as run-time options....
by tpyo kingg
Mon Feb 18, 2019 7:43 pm
Forum: Raspbian
Topic: Bash script command to check swap and show error?
Replies: 8
Views: 158

Re: Bash script command to check swap and show error?

If you are combining grep with head or tail a lot you might look at awk instead on many of those occasions. SWAPSPACE=$(free | awk '$1=="Swap:"{print $2;exit}') The above will capture the first and maybe only swap. If you go with grep the -P option you've found is very useful even if experimental. I...
by tpyo kingg
Mon Feb 18, 2019 3:00 pm
Forum: Advanced users
Topic: transfering files from RPi Zero over serial
Replies: 4
Views: 87

Re: transfering files from RPi Zero over serial

Thanks. That was the pointer I needed. I have sz and rz on both machines now. To stay lazy, I'm sticking with screen for the serial connection but it works quite well anyway. As for the details, in order to receive a file over screen, it is necssary to tell it to act as a zmodem end point: ^A:set zm...
by tpyo kingg
Mon Feb 18, 2019 12:55 pm
Forum: Beginners
Topic: I need project ideas for the Raspberry Pi 3 B?
Replies: 5
Views: 137

Re: I need project ideas for the Raspberry Pi 3 B?

It also comes down to what you are starting to get interested in. So find something in the intersection between what is required for the certifcation and what you'd like to learn. The print server idea is really useful in a lot of situations. If you are looking for web activities, you might try inst...
by tpyo kingg
Mon Feb 18, 2019 12:27 pm
Forum: Advanced users
Topic: transfering files from RPi Zero over serial
Replies: 4
Views: 87

transfering files from RPi Zero over serial

I'd like to get some files from a Raspberry Pi Zero W using the serial console, so as to avoid retooling the network configuration for a one-off activity. I know serial file transfers were feasible in either direction back in the kermit days. What are the current methods to do this? If it matters, I...
by tpyo kingg
Mon Feb 18, 2019 5:46 am
Forum: The MagPi
Topic: Surprised to see you promoting W10
Replies: 11
Views: 380

Re: Surprised to see you promoting W10

At the same time, since these tiny ARM-based machines are starting to be used by the fashionable elite as desktop computers, it makes sense for Microsoft to get interested in making their software compatible. It won't run convincingly though. While the 3B+ doesn't compete against high end hardware,...
by tpyo kingg
Sun Feb 17, 2019 5:41 pm
Forum: Raspbian
Topic: Bash script command to check swap and show error?
Replies: 8
Views: 158

Re: Bash script command to check swap and show error?

You could use AWK:

Code: Select all

free | awk '$1~/Mem/&&$2>1000000{print $2; exit 1}'; 
echo $?;
That'll work within an if-then-else shell statement.
by tpyo kingg
Sat Feb 16, 2019 1:45 pm
Forum: Beginners
Topic: Raspberry Pi 3 B+ Web Server Hosting
Replies: 3
Views: 87

Re: Raspberry Pi 3 B+ Web Server Hosting

With Raspbian, most of the generic nginx or Apache2 guides written for the Debian family of distros will be applicable. As for content management systems (CMS), Drupal and WordPress are quite common, especially the latter, but they are very heavy and complicated. It might be worth looking at a stati...
by tpyo kingg
Fri Feb 15, 2019 7:41 pm
Forum: Beginners
Topic: How to remove last N entries from bash history?
Replies: 4
Views: 114

Re: How to remove last N entries from bash history?

rc.local runs as root, you probably want something to affect the pi account instead. The history file is accessible directly, it is a file after all. So from within rc.local, you might try t=$(tempfile -d /tmp/); head -n -24 /home/pi/.bash_history > $t && mv $t /home/pi/.bash_history; chown pi:pi /h...
by tpyo kingg
Fri Feb 15, 2019 12:44 pm
Forum: Beginners
Topic: unable to exec a script via php [SOLVED]
Replies: 3
Views: 67

Re: unable to exec a script via php [SOLVED]

When combined with the PHP script being owned by the web server process, that sudoers configuration potentially provides a great entrance to your system as root. Think instead least privilege. control.py and trigger.py should not be owned by www-data. That account (and group) is instead for isolatin...
by tpyo kingg
Thu Feb 14, 2019 12:11 pm
Forum: Beginners
Topic: How To Execute a Script at Shutdown/Halt on Raspbian Stretch
Replies: 10
Views: 212

Re: How To Execute a Script at Shutdown/Halt on Raspbian Stretch

There are probably many ways to get more or less the same result. Based on tests I get the impression that systemd sometimes has inconsistent behavior. Many times it even fails to boot until power cycled. Anyway, the following are two of the ways I've gotten a script to trigger upon shutdown. $ cat ...
by tpyo kingg
Wed Feb 13, 2019 7:21 pm
Forum: Beginners
Topic: How to stop multiple scripts that are running simultaneously?
Replies: 8
Views: 162

Re: How to stop multiple scripts that are running simultaneously?

The PID method is good even if it does have some down sides, including needing a way to remove it when the program quits or is killed. One other way which would make it possible to use the utilities pgrep and pkill would be to set your python scripts to launch directly. Make each file executable and...
by tpyo kingg
Wed Feb 13, 2019 5:51 pm
Forum: Beginners
Topic: A basic setup that randomly turns on a light for a random time.
Replies: 8
Views: 157

Re: A basic setup that randomly turns on a light for a random time.

If you can do it to code, so you'd have to wire everything up yourself, including the fuses and plugs, I have seen online that there are several relay boards for switching mains current. Of those the Raspberry Pi Relay Board is one, but I have seen others. There are also more complete things like th...
by tpyo kingg
Wed Feb 13, 2019 7:25 am
Forum: Beginners
Topic: Hello I'm new to raspberry pi and the forums but need your help - GPIO over internet
Replies: 1
Views: 87

Re: Hello I'm new to raspberry pi and the forums but need your help

But I cannot seem to get it to access outside of my network for some reason [...] Do you have the GPIO working with PHP locally over the LAN yet? That is the first step before even considering opening up external ports on the router. Then once you do have GPIO access via PHP to set up password prot...
by tpyo kingg
Tue Feb 12, 2019 2:05 pm
Forum: Beginners
Topic: web link query?
Replies: 3
Views: 68

Re: web link query?

If you sign up for Let's Encrypt , which is free-of-charge, you'll be able to upgrade to HTTPS at least. With HTTP, all your traffic is transferred unencrypted, including the FTP link containing the FTP user and FTP password. With HTTPS at least your initial connection is encrypted, which is better ...
by tpyo kingg
Tue Feb 12, 2019 10:46 am
Forum: General discussion
Topic: Can we send commands via webpage
Replies: 1
Views: 81

Re: Can we send commands via webpage

Well, that's quite easy, if you are careful. On the PHP side of things you could use exec() or system() to call system utiltilities: /usr/bin/sudo /usr/bin/apt-get update; /usr/bin/sudo /usr/bin/apt-get -y upgrade; /usr/bin/sudo /usr/bin/apt-get -y dist-upgrade; /usr/bin/sudo /sbin/reboot; Be very c...
by tpyo kingg
Mon Feb 11, 2019 5:18 pm
Forum: Beginners
Topic: How To Execute a Script at Shutdown/Halt on Raspbian Stretch
Replies: 10
Views: 212

Re: How To Execute a Script at Shutdown/Halt on Raspbian Stretch

Did you reload the systemd services and (re-)start the service once you changed the service file?
by tpyo kingg
Mon Feb 11, 2019 11:15 am
Forum: Beginners
Topic: How To Execute a Script at Shutdown/Halt on Raspbian Stretch
Replies: 10
Views: 212

Re: How To Execute a Script at Shutdown/Halt on Raspbian Stretch

I had an error in the example above. Try the two together:

Code: Select all

[Service]
RemainAfterExit=yes
Type=oneshot
ExecStop=/bin/echo "cmd=switchoff" > /dev/ttyACM0
by tpyo kingg
Mon Feb 11, 2019 10:51 am
Forum: Raspbian
Topic: Easiest way to send a looped string to /dev/ttyAMA0?
Replies: 3
Views: 81

Re: Easiest way to send a looped string to /dev/ttyAMA0?

Why not a while loop and a redirection?

Code: Select all

while sleep 2;
do
        echo "foo" > /dev/ttyAMA0
done
by tpyo kingg
Mon Feb 11, 2019 8:00 am
Forum: Raspbian
Topic: Different operating systems
Replies: 2
Views: 113

Re: Different operating systems

Also, if you start to go that route, you might want a small box, with space to write a word or two, or something else to hold the spare microSD cards when not in use. You can then more easily have otherwise incompatible projects on the same hardware. Myself, I use a card holder with labeled slots an...
by tpyo kingg
Sun Feb 10, 2019 6:32 am
Forum: HATs and other add-ons
Topic: RS232 without using GPiO help please?
Replies: 10
Views: 256

Re: RS232 without using GPiO help please?

It is the chipset in the adapter which is relevant for support. That cable uses the PL2303 and that is well supported. If you plug it in, you can look at the information it provides to the system: lsusb | less lsusb -v | less Scroll down to where it says "Prolific Technology, Inc. PL2303 Serial Port"
by tpyo kingg
Sun Feb 10, 2019 5:59 am
Forum: General discussion
Topic: Zero W-based portable computer with 3D-printed case
Replies: 0
Views: 70

Zero W-based portable computer with 3D-printed case

There's an interesting blog post about using the local public library's 3D printer to make a case for a portable computer built from a Raspberry Pi Zero W: http://txti.es/thetrakynia The case was modeled in Blender and the other parts are off-the-shelf. The photos show it from different angles. It h...
by tpyo kingg
Sat Feb 09, 2019 7:28 pm
Forum: General discussion
Topic: Installed Apache, how to secure?
Replies: 9
Views: 222

Re: Installed Apache, how to secure?

I'd add to those to stick with stock Apache2 and stay with static pages as much as possible. You can get standardized headers and footers and menus using Server-side Includes (NoExec). The next step up would be a static site generator, like Jekyll, Hugo, or Pelican. Those would allow the public-faci...
by tpyo kingg
Fri Feb 08, 2019 4:53 pm
Forum: Beginners
Topic: How To Execute a Script at Shutdown/Halt on Raspbian Stretch
Replies: 10
Views: 212

Re: How To Execute a Script at Shutdown/Halt on Raspbian Stretch

It would need to have RemainAfterExit also.

Code: Select all

[Service]
RemainAfterExit=yes
Type=oneshot
ExecStart=/bin/echo "cmd=switchoff" > /dev/ttyACM0
by tpyo kingg
Fri Feb 08, 2019 11:01 am
Forum: Python
Topic: Deleting directory created by other user
Replies: 5
Views: 139

Re: Deleting directory created by other user

chmod 775 "images" to give the "pi" group "w" on "images". When creating new "seq" directories chmod 775 to ensure group has "w". You'll still probably need the set-group-ID bit, which would be mode 2775 or g=rwxs, to ensure that the right group is always used. Otherwise it will end up being the de...

Go to advanced search