Mostrando entradas con la etiqueta file. Mostrar todas las entradas
Mostrando entradas con la etiqueta file. Mostrar todas las entradas

18 nov 2024

HOW TO make a online available folder store images downloaded from internet website in a certain interval of time.

--> Create your apache webserver. 
Then go  /var/www/html/ and make sure no index.html file is present. 
This way we will access the folder directly to access raw data.

Do not forget to mount yor external data drive (in order not to 
overcome OS drive capability with time) and EDIT YOUR /etc/bash.rc 
file adding the info bellow to do it every time you reboot. Best practice here!

--> Now create the script that will run to download images, starting from boot 
and lasting for computer's uptime. 

both things are done by editing the /etc/rc.local file in your raspberry pi.        
____________________________________________________________________________________________________________________
|   sudo mount /dev/sda1 /var/www/html &                                                                            |
|                                                                                                                   |
|   sudo watch -n 14400 wget -P /var/www/html/ https://sdo.gsfc.nasa.gov/assets/img/latest/latest_2048_HMII.jpg &   |
|                                                                                                                   |
|   exit 0                                                                                                          |
|___________________________________________________________________________________________________________________|

--> Run the necesary permissions update command

    
    sudo chmod +x /etc/rc.local


--> here -as an example- we are downloading a sun picture provided by nasa, 
every 4 hours (time in seconds)

... Now we wait and see the results.

I used imagemagick convert to create the funny ani.gif file! 
	
	sudo convert -delay 20 -loop 0  *.jpg.* ani.gif
	
...rollin`good up to date!

23 jul 2023

find & replace expressions inside a text file running a simple python script in GNU-Linux terminal

FILE 1 (BEGIN)

readMe.txt

································································································

Hi!

This set of files is just a little experiment to do some work over a file with a python script.

File "example.txt" contains expressions that will be replaced with new ones as described on “findAndReplace.py” file in this folder. (there is an “.example.txt” file to have it back again in case you want to. Just make it visible and take the “*.hackUp” fake extension).

See it in action by running the “doAll.sh” batch file as root. Remember to “chmod 755 file2change” to the files if you find it suitable. To install stuff you’ll need internet (o_o)

have fun!

(=

································································································

FILE 1 (END); FILE 2 (BEGIN)

findAndReplace.py

································································································

from pathlib2 import Path
# import some libraries
path = Path("example.txt")                  
# file located in the same folder. tune to your desired route, like /home/user/whatever
text = path.read_text()
# read the file
text = text.replace("=)", ":)")
# replace whatever is necessary
path.write_text(text)
# and finally overwrite the file.

# I had to install...       apt-get install python-pip python3-pip -Y
# & after alsa ...          pip install pathlib2 -Y
# due to                    module not loadad error
# ;-)

# do run from terminal...   python findAndReplace.py


# CC Share alike too the latest! ONLY FOR EDUCATIONAL MEANS!!

································································································

FILE 2 (END); FILE 3 (BEGIN) 

example.txt

································································································

=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)

································································································

FILE 3 (END); FILE 4 (BEGIN)

.example.txt.backUp 

································································································

=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
=) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =) =)
 

································································································

FILE 4 (END); FILE 5 (BEGIN)

doAll.sh

································································································

#!/bin/bash

apt-get update

apt-get upgrade -y

apt-get install python -y

apt-get install python-pip python3-pip -y

pip install pathlib2

python findAndReplace.py

································································································

FILE 5 (END)

 

# pseudocode is not a crime!