All Questions
186
questions
2
votes
2
answers
70
views
Avoiding accidental execution of python scripts as bash scripts
I like to run my python scripts directly in bash like so
$ ./script.py
But sometimes I forget the shebang line #!/usr/bin/env python3, and it has the potential to overwrite a file named np if the ...
0
votes
0
answers
138
views
Cannot activate Python virtual environment from within shell script (zsh)
I cannot activate a Python virtual environment from within a shell script (zsh).
I have tried the following:
#!/bin/zsh
conda create -n myenv python=3.10
conda activate myenv
It sends me the error ...
2
votes
1
answer
140
views
Algorithm to find longest common substring
I'm having a bit of trouble coming up with a general solution to the following problem.
First a bit of context.
End goal: set file permissions on all files and directories created by a rpm
My plan was ...
1
vote
0
answers
86
views
In Debian 11 docker container, I cannot type lowercase S when I switch to bash from zsh
When I connect to my Docker container with Debian 11 via ssh, I have it set up such that zsh is the main shell. When I switch to bash (by typing bash) I lose the ability to type the lowercase letter s ...
0
votes
0
answers
949
views
Using rsync and ssh inside python script to specific folder
I am attempting to make a copy of the /home folder on a remote Raspberry Pi (pitwo) to a local Raspberry Pi (pizero) via rsync and ssh. The local Pi has a hard drive connected that is shared using ...
1
vote
1
answer
279
views
How to extract numbers from rsync stats output
I am using rsync to back up a Raspberry Pi. The rsync command runs inside a python script:
import os
os.system('sudo rsync -avzh --stats /etc /home /usr /mnt/BigMac/BigMac/PiBackups/PiZero')
The ...
1
vote
1
answer
941
views
How to have one process listen to a serial port that another process is writing to?
I have a process (in bash) that writes data to a serial port. I would like to see that data, but instead of hooking up an Arduino and showing the data on a display, I thought it would be easier to ...
1
vote
1
answer
398
views
How to find the "pattern" in FASTA file and record the cordinates along with header
I am looking for a solution to search for a string of 17 base pairs in the FASTA file that is the human reference genome.
To clarify, in simple words and put the resources, i have tried grep function ...
0
votes
0
answers
41
views
Reenter interrupted session with running script
On a server I ran a debug intense script and unfortunately my session was interrupted (broken pipe).
I logged in again and apparently the script is still running:
PID USER PR NI VIRT ...
0
votes
0
answers
247
views
Singularity exec gives environment error when running python script, but the python script can be run interactively fine
When running these two commands sequentially in a terminal,
singularity run /home/___/singularity_containers/singularity_container.simg bash
python3 /home/__/__/___/src/python_file.py
Everything ...
0
votes
1
answer
578
views
How to run singularity container and python code from within the singularity container in a shell script?
I am trying to start a singularity container and then run a python script from within that container. The commands work individually if I run them outside, but as soon as I put them in a shell script ...
0
votes
0
answers
53
views
I created a cronjob years ago, now it is still running on the server but I can't locate it with "crontab -e", what can I do?
two years ago I created a cronjob which execute a python script to backup stuff. Now, the thing is that this cronjob is still running:
/var/log/cron.log.1:Oct 9 20:00:02 syslogngsrv CRON[28292]: (...
0
votes
0
answers
8k
views
Job for service failed because the control process exited with error
I'm trying to run a service manually, and everytime I get the folling messages:
user1@machine:~/Tools/systemd_tools$ sudo systemctl status tool_fd.service
● tool_fd.service - automatic tool service
...
1
vote
1
answer
558
views
Bash $_ in Python os.system
I just ran into the following
grep -h ^ID= /etc/*-release
python -c 'from os import system; system("echo hello; echo $_")'
for RHEL, this gives what i expect ($_ expands to hello):
$ grep -...
1
vote
1
answer
379
views
How to properly make a SSH-call LOCALLY async/background/independent/...?
Use-case
I have a backup software able to read data to be backed up from named pipes. I want to use that feature to backup database dumps of e.g. MySQL and PostgreSQL which are hosted within multiple ...
2
votes
1
answer
14k
views
Executing a python script via SSH on remote and scp on localhost
I am new to this and need some advice on resolving my problem.
I have a python script on a remote server. I want to execute that script from my local system and then transfer the result file generated ...
0
votes
1
answer
4k
views
How to put colors in terminal?
I would like to use rgb(a) hex codes to display colors on the terminal.
I intend to make some kind of program that can render colors inside brackets, like: [#FFFFFF]this is white text
1
vote
0
answers
2k
views
NodeJS can't find python: gyp ERR! find Python
I'm trying to run a script but nodejs can't find python for some reason. I have tried reinstalling python, reinstalling nodejs, reinstalling my OS, running (and rebooting afterwards): export PYTHON=&...
0
votes
1
answer
621
views
Why jupyter notebook won't start?
I installed jupiter notebook via macOS console:
pip3 install notebook
but when trying to launch (jupyter notebook/Jupyter notebook) the console writes that the command was not found:
zsh: command not ...
2
votes
1
answer
2k
views
Why is my script running if run with cli but not with crontab?
On WSL Ubuntu 20.04 I have two scripts (one sh and one python) that run perfectly if I launch them with bash, but not with cron.
The second (python) script is supposed to run just if the first (bash) ...
1
vote
1
answer
2k
views
PATH still affected by Anaconda after uninstalling
When I run echo $PATH in terminal (macOS), it returns /opt/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin. I have uninstalled anaconda and both my opt directory and .bash_profile are empty....
1
vote
1
answer
493
views
Trying to run a python script on startup on my raspberry pi
I've googled how to do this but I don't understand enough about linux to be able to interpret the answers.
I ssh into my pi and log in using the user 'pi' and the password I set.
Then I type sudo -s ...
0
votes
1
answer
62
views
Copying image files listed in a file from multiple sub directories to one common directory
I have around 8 sub directories that have image files in them. I need to move 300 of around 6000 photos from those sub directories to one common directory. I have a file with the names, not the ...
0
votes
1
answer
67
views
Running system rm -rf on an online compiler
I have not written the command using proper syntax in order to prevent any accidental misfire
I recently read about the danger of using the command rm -rf in root directory but was wondering about a ...
2
votes
2
answers
20k
views
How to properly upgrade gcc on Centos 7?
I did this to upgrade gcc from 4.8.5 to gcc 7:
sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
source /opt/rh/devtoolset-7/enable
This does give me the gcc 7 in the current ...
1
vote
0
answers
37
views
How to change the target directory of target-csv when running tap-target script inside python? [closed]
I am trying to a script run.sh using python subprocess
The script creates a csv file and a state.json file in the cwd
This is the script(works fine when i run it from terminal) :
#!/bin/bash
export ...
2
votes
1
answer
2k
views
How do I stop a screen capture with FFmpeg under Windows in a bash script?
When I capture the screen with ffmpeg -i desktop in a Bash script under Windows, I cannot end the capture with taskkill /f, because then FFmpeg won't write the MP4 header.
It has to be shutdown with ...
1
vote
0
answers
128
views
Unable to set python environments with old interpreters
I have installed virtualenvwrapper on Arch Linux, as well as the AUR repository python38 so I can set an environment and work with TensorFlow. I have set up .bashrc as usually recommended on the docs ...
0
votes
1
answer
362
views
FFMPEG with Python Automation Script
I am new to bash and I want to stick to Python to call bash scripts if required.
My setup.
Plex Server.
Google Drive Rclone.
Transcoding Server.
The question is related to the transcoding server.
I ...
1
vote
3
answers
13k
views
find duplicate record in Text file
I have text file with this kind of structure
mv /XXX/20000/XXX-18245 /XXX/20000/XXX-28042
mv /XXX/10000/XXX-9942 /XXX/10000/XXX-18166
mv /XXX/10000/XXX-9962 /XXX/10000/XXX-18189
mv /XXX/20000/XXX-...
0
votes
1
answer
586
views
my terminal is not recognizing my flask command after i installed flask
I ran into a problem with the terminal, it didn't recognize my flask command!
the whole issue started with
WARNING: The script isort is installed in '/Users/bigdad/Library/Python/3.8/bin' which is not ...
0
votes
1
answer
279
views
monitor PID and respawn processes in bash script (simulatord, nc, ping)
For a student environment, I have a simple bash script that runs upon boot up on Ubuntu 18.04 (@reboot in crontab -e).
It runs ok (java file starts, netcat starts, pings, and all PIDs are viewable via ...
1
vote
1
answer
1k
views
execute python script in interactive subshell
I have a python script that needs to be run in an interactive shell (it monitors for certain cancel key input events, which i dont need).
I want to execute this script in the background, grab its ...
2
votes
0
answers
914
views
Redirect Output of python to file [closed]
I have the following problem:
I need to redirect standardoutput to output.file
I have a script that is written in python (I have no clue about python). I run the script using a bash terminal in ...
4
votes
2
answers
538
views
How can I automatically download and archive my own YouTube videos? [closed]
I want to download all my YouTube videos (potentially hundreds or thousands, including live streams).
I have MANY private YouTube videos that are really for my own personal usage.
I am beginning to ...
1
vote
0
answers
649
views
Permission Denied While Running Script
I am attempting to run a script from the shairport-sync service with this command:
run_this_after_play_ends = "/home/pi/Watson/testmicend.sh"
/home/pi/Watson/testmicend.sh:
#!/bin/bash
...
1
vote
0
answers
4k
views
Running command-line tools giving python3 bad interpreter, no such file or directory error
I have two versions of python installed on a server: /usr/local/bin/python3 (version 3.6.3) /home/ubuntu/miniconda2/bin/python (version 2.7.15)
Earlier today I removed python version 3.6.3 and 3.4.0 ...
0
votes
0
answers
1k
views
Why zsh shell is running Python 3 while bash is running Python 2 on Mac OS
I just bought a new MacBook running macOS Catalina version 10.15.5.
After installing Anaconda, Homebrew, Git, etc, I've noticed that the shell I'm running is not bash, rather it's zsh—which i'm ...
0
votes
1
answer
613
views
Cron job doesn't work
I have a shell script which I want to run as a cron-job every 10 minutes. I'm adding the job as follows
crontab -e
*/10 * * * * /bin/sh /home/tool/fill_data/run_script.sh
And the run_script.sh ...
1
vote
0
answers
2k
views
Screen session dies randomly and how can I diagnose the reason?
I'm using a Python script with screen session but it dies randomly and I checked syslog files for an error (which mentioned on Screen and SSH Tunnel - How can screen session possibly die?) but couldn'...
3
votes
2
answers
1k
views
how do I write a line number divisible by 3 in bash from an input file?
Create a shell script which prints the line contents when the line number is divisible by 3 from an input file. Assume the first line is line 1. At the end of the script, if the total number of lines ...
5
votes
3
answers
52k
views
How to activate python virtualenv through shell script?
0
I have to activate the virtual environment (venv) so I running these commands manually in terminal:
source .venv/bin/activate # To activate the virtual env.
and
deactivate ...
1
vote
0
answers
418
views
Problems with Atom, Linter, linter-flake8 and bash
I just installed Atom editor and some packages, like linter and linter-flake8.
When I try to edit python code, I receive the following error:
[Linter] Error running Flake8 Error: /bin/sh: module: ...
0
votes
1
answer
459
views
how to pipe:/// through a .sh or Python script, or use some sort of setting files with FFMPEG
First post on superuser, so be kind please :)
So a quick bit of history. I am using tvheadend, and the inbuilt transcoder murders my CPU, and provides average quality output (it's powered by ffmpeg), ...
0
votes
1
answer
2k
views
Get Python Version with Bash Script
I have a script that gets the python version from clients. The command in bash is:
pythonVer=$(ssh $user@$ip "python --version")
But this command shows the python version on stdout (my ...
0
votes
1
answer
675
views
Cron call to script giving errors, while executing script normally doesn't
I have been having problems with executing a script every second with Cron.
This is in my cron file:
* * * * * /var/webconfig/test.sh
and this in my test.sh :
#!/bin/bash
cd /root/python-example ...
2
votes
0
answers
212
views
pycurl and curl not working without sudo
sorry for my poor English
i have more than two network interfaces and i want send request with specific interface .
here is my code in with pycurl:
def curl_post(url, data, iface=None):
c = ...
0
votes
0
answers
3k
views
How to open an image on remote computer via SSH? (Ubuntu)
I am looking for a way to display an Image Remotely
For example,
1. user foo is viewing Ubuntu 16.04 computer via monitor
2. I am connected through SSH to user's foo computer
3. I want to display ...
0
votes
0
answers
612
views
Trying to run a Python script as sudo with Windows interpreter inside WSL, but got "file not found"
I have a python script in my WSL Debian called pasman, which is in my home directory bin folder, where I keep my custom scripts. I have an export statement in .bashrc file so that I can run this ...
1
vote
1
answer
267
views
Texmacs Ubuntu 18.04.03 and Python
I am trying to install TeXmacs for Ubuntu, but it is not available via apt-get. The instructions on the site tells us to download a zip and run it through a bash script (https://www.texmacs.org/tmweb/...