All Questions
73 questions
22votes
4answers
60kviews
Using Python in a Bash Script [duplicate]
If I try to start python in a bash script, the script will stop running and no commands will execute after "Python" is called. In this simple example, "TESTPRINT" will not be printed. It seems like ...
22votes
5answers
14kviews
How can I have more than one possibility in a script's shebang line?
I'm in a bit of an interesting situation where I have a Python script that can theoretically be run by a variety of users with a variety of environments (and PATHs) and on a variety of Linux systems. ...
21votes
8answers
165kviews
how to execute a bash command in a python script
How can I launch a bash command with multiple args (for example "sudo apt update") from a python script?
14votes
2answers
12kviews
is there a way to get the url from current tab in google-chrome?
I used to do that on firefox using a python command, but recently something changed and I can't get the URL anymore! What used to work with firefox: #!/bin/bash current_tab_num () { python2 <&...
11votes
4answers
22kviews
Hybrid code in shell scripts. Sharing variables
This answer discusses how to run a multi-line Python snippet from the command line in a terminal. I noticed that the answer works great within shell scripts, even with nested indentation, which is ...
11votes
3answers
3kviews
python == python2 OR python == python3 ? How to package, distribute python py2k scripts?
Depending on system, python==python2 or python==python3. Executable Python scripts, starts with: #!/usr/bin/env python #!/usr/bin/env python2 #!/usr/bin/env python3... For python py3k it is provided ...
7votes
4answers
4kviews
Problems running python script from motion
I'm trying to set up the raspberry pi with my webcam as a motion detecting cctv that uploads the videos to google drive using Jeremy Blythe's script I have motion working correctly and the python ...
6votes
1answer
22kviews
How to run multiple scripts one after another but only after previous one got completed?
I have to run several python scripts one after another but want to make sure previous one got completed. How can I do that in Linux? Can it be done by simply using && or ; or | ?
6votes
4answers
52kviews
getting output from netcat, decoding it and returning an output
I have to get an output from netcat, decode it and return it. after typing: nc cs2107.spro.ink 9000 the output i get is this: Welcome to the Proof of work challenge! Rules: i will provide hex ...
5votes
3answers
5kviews
Wait until gnome-terminal ends
I'm trying to implement a script who runs four terminal window in parallel using this function gnome-terminal -e sh -c "python scraper.py". I would like to know if there's a way to wait until each ...
5votes
4answers
39kviews
piping python variable value to bash script (inside python script)
After years of bash scripting I've been given the task of modifying a python script to have it call a shell script when certain conditions are met. That part wasn't too bad, but now I'm trying to ...
5votes
1answer
7kviews
View script output over ssh in real time
I am trying to run a local script on a remote machine with ssh. Let's say this is the python script (printdelay.py) which I am trying to run: from time import sleep print("The first line") sleep(...
5votes
1answer
4kviews
How do I properly change the debian default python 2.7.9 to python3 or another version? [duplicate]
what is best-practice for changing the default global python interpreter on my fresh debian-based linux node to python3.x? When I create a fresh Debian or Ubuntu VM, one of the first things I do is ...
4votes
7answers
9kviews
Convert a list of decimal values in a text file into hex format
I have a need to convert a list of decimal values in a text file into hex format, so for example test.txt might contain: 131072 196608 262144 327680 393216 ... the output should be list of hex ...
4votes
1answer
5kviews
Convert xml subtitle file to srt format
I have a xml subtitle that looks like this: <?xml version="1.0" encoding="utf-8" ?><transcript> <Item from="1.16" duration="4.68"><![CDATA[(Dong-hyuk is coming to see you now.) ...