Skip to content

How do I correctly run scripts? #18

@MeesjeKeesie

Description

@MeesjeKeesie

This may not be the correct place to ask this in, but I got it working with Linux and Ubuntu, but for research purposes, I need to run a script to send some data to another node. I've created the script (python file) but I've also get the warning that the disk is protected against writing, and I don't know how I can place it into my virtual enviroment. Is there someone who can help me, and give me a brief explanation on how the script command works?

The script I want to implement:

import subprocess
from datetime import datetime

#Contact and message
contact = "BC904423" / The contact I want to send a message to and is in my contact list
message = "Hello, this is a test message with timestamp"

#Exact Time (UTC or local time, dependand of my module, idk)
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

#Combine message and time
full_message = f"{message} @ {timestamp}"

#Serial Port
serial_port = "/dev/ttyUSB0"

#Building command
cmd = [
    "meshcli",
    "-s", serial_port,
    "msg", contact,
    full_message,
    "wa"  # wa = write and acknowledge
]

#Run
result = subprocess.run(cmd, capture_output=True, text=True)

#Show output
print("Sent:", full_message)
print("Result:", result.stdout)
print("Error:", result.stderr)

As a somewhat intermediate coder myself I think this code should be totally fine running, but it's just that I can't seem to upload it to my .venv and I really don't know where to place it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions