All Questions
Tagged with python command-line
45
questions
0
votes
0
answers
71
views
Write output of multiple python scripts to single file
I used to have only one python script, of which the output would be directed to a log file.
It works like this, I have it in the autostart, using crontab.
@reboot /bin/sleep 30; sudo /usr/bin/python3 -...
0
votes
1
answer
342
views
How to `import FreeCAD` in CLI (python)
How can I import FreeCAD from the python console?
I'm trying to write a script that can manipulate a given FreeCAD file, but I can't even get FreeCAD imported into the python console on a system where ...
0
votes
2
answers
421
views
python script to get the apt-get update command history with date
I am writing a python script to get the apt-get command history with a date. Passing IP address and password as a parameter, then SSH into the host. In the command list, we have a list of Linux ...
0
votes
5
answers
95
views
How to remove the final \n?
Using a CLI command in Python ps -au | awk '{print$1,$2,$3,$4,$7,$11}' | sed '1d' to obtain the following output:
root 669 0.0 0.0 tty1 /sbin/agetty
root 670 0.4 2.8 tty7 /usr/lib/xorg/Xorg
lothar ...
1
vote
1
answer
860
views
Interacting with GUI from CLI (headless GUI)
I have linux server.
I expect there's headless GUI that can be controlled by CLI for my server.
I do know it possible display GUI with XRDP. But I expect I can control it with SSH or CLI. It works ...
0
votes
1
answer
664
views
Dynamically generate arguments for python script input
I call a python script with some command line arguments like:
python3 script.py --run 1 --filepath "this/file/dir"
I now try to parse the arguments from a config file with:
grep -v '^#' ${...
2
votes
1
answer
345
views
Is there a way to change GTK theme for one session in ANY desktop environment?
When I search for a way to change the gtk theme in Linux, I find that there is a different way to do it for every desktop environment. The only one I found that worked on all desktop environments was ...
0
votes
0
answers
23
views
My variable seems to change when passed into a CLI [duplicate]
I am attempting to use a java based program, CRFVoter, for text mining. I called and executed the script as specified.
[user]$ java -jar CRFVoter.jar
usage: CRFVoter GPRO
Command Line Tool for ...
0
votes
0
answers
27
views
How to manually send a log file with specefic count and rate to a server
I have a txt log file (syslog format) that i want to send it with specific count(number of lines) and rate(logs per second) to a server (ELK Stack) that parse this logs on port 514.
i see the logger ...
0
votes
1
answer
1k
views
Error :“the command '/bin/sh -c source protected-env/bin/activate' returned a non-zero code: 127” while I'm trying to configure my first dockerfile
I'm trying to learn docker. This is my first experiment. I have written this dockerfile :
FROM nvidia/cudagl:11.3.0-base-ubuntu20.04
LABEL Author="ZioMario"
LABEL Title="Firefox/...
2
votes
1
answer
287
views
How to get data from VLC player
I need a command or a python code to get all data like the name of the file which is playing in VLC and hour:minute:second of the video.
Sample Output:
pc@system: $ TheCommandLine
File : /home/rev/...
0
votes
1
answer
589
views
AttributeError: module 'serial' has no attribute 'to_bytes'
Iam trying to program Arduino Uno using python program. My python version is python 3.8. I successfully installed the pyfirmata2. but when i tried to import pyfirmata2 from command line iam getting ...
0
votes
1
answer
1k
views
Command not found despite having just installed it?
As you can see in the screenshot below, I install a command (it's a wrapper for a program called qsiprep), and then try running it, but it says it's not installed...any ideas as to what is happening?
...
0
votes
0
answers
438
views
Use python script with pymol, via linux command line?
I'm trying to run Python scripts t5.py that calls in pymol using linux terminal (CLI only), and I'm not too sure why it doesn't work. Below is the message that I got when typing pymol t5.py in the ...
0
votes
0
answers
396
views
How to restore the console after a call to clear (similar to less)?
How do I clear the the console window, then do something with it (move the cursor, write something somewhere) and then put it back how it was before?
Similar to how less, vi or man.
I've heard about ...
-1
votes
1
answer
845
views
What is --data-dir=${PWD} in my tutorial instructions?
I am following instructions in a tutorial.
Download the CIFAR-10 dataset and generate TFRecord files using the provided script. The script and associated command below will download the CIFAR-10 ...
1
vote
1
answer
575
views
Failed to build setup.py on Arch Linux
I currently installed Arch Linux and I want to install the wxPython module for Spyder3. I had problems installing it with pip. Therefore, I downloaded the wxpython tarball. Here are the steps which I ...
1
vote
1
answer
1k
views
How to procedurally generate command in bash script using string interpolation with spaces?
I'm trying to create a simple script that uses a list of months like this:
(Jan Feb)
To generate and execute this command:
python ExpenseManager.py -p Inputs/Jan\ 2019\ Debit.CSV Inputs/Jan\
...
3
votes
1
answer
1k
views
Tool to determine MP3 actual quality
I am looking for a CLI tool that will give me an output of the frequency range of an MP3 file, like Spek does, but without the image file. I need to this to analyse a large library of MP3 files to ...
1
vote
0
answers
221
views
How to configure Atom for Python?
I installed atom-python-run for running python in Atom. But when I installed python extension in VS Code, then a massage came in that pylint not installed. And I clicked in install button. then a ...
0
votes
1
answer
38
views
pass a string with non printable char in hexa to a
I want to pass a string in hexa :
'c3:87:80:00'
by instance to a binary
I've tried :
./<bin> "$(python -c "print 'c3:87:80:00'")"
and
./<bin> "$(printf 'c3:87:80:00')"
I've also ...
0
votes
1
answer
587
views
Is it possible to put the output of one command into the middle of another [duplicate]
I am asking if there is a way to automatically put the output of a command into the middle of another.
multimon-ng outputs: ZCZC-WXR-TOR-029037+0030-1051700-KEAX/NWS and i want that output to get ...
0
votes
1
answer
185
views
Extract data based on second column [closed]
Now I have a file format like
ACTG,CD1,234
BGTY,CD2,561
CFRT,CD3,27
DGTY,CD4,45
EYTG,CD5,23
FJUI,CD1,78
GYHJ,CD2,89
HYHG,CD3,107
IUHJHU,CD4,55
JMJGT,CD5,77
I want my output file like:
CD1,ACTG,234
...
0
votes
1
answer
4k
views
How to use the bash shell with Python in place of /bin/sh
I have commands that could be executed in a terminal, but I want to execute them directly from my python script, except that my script it launches the commands in /bin/sh, and my terminal is bash.
...
0
votes
1
answer
2k
views
How can I run the sudo command in Python code under CentOS in Docker
I am trying to access the docker image labels from Python as follows
hostname = socket.gethostname()
cmd = "sudo curl --unix-socket /var/run/docker.sock http:/containers/" + hostname + "/json"
output ...
1
vote
1
answer
439
views
program called twice from the command line [closed]
Let's say I have a (Python3) script of my own named myscript; for various reasons, myscript (not myscript.py) is stored in a sub-directory named bin :
mydir/
mydir/bin/
mydir/bin/myscript -rwxr-...
3
votes
2
answers
17k
views
search through all *.py files [duplicate]
I am using Mac OS terminal (similar to Linux) and trying to find best way to search inside all files on a computer that has extension *.py
What is the best way to achieve this?
I wanted to put 1 ...
2
votes
1
answer
1k
views
How do I detect a command is being executed and then execute an additional command after the current command
I want the shell to detect that I had run a specific command and then after running the command, run another command.
For Example : When every I run the command : git commit -m " "
First finish the ...
0
votes
1
answer
619
views
Run python script without declare it interpreter
I have such a program to check methods of data from the command line:
me at me in ~/Desktop/Coding/codes
$ cat check_methods.py
#! /usr/bin/env python
from sys import argv
methods = dir(eval(argv[1]))...
0
votes
1
answer
1k
views
powerline error in command line
I installed powerline by this way:
pip install --user powerline-status
pip install --user git+git://github.com/powerline/powerline
After that I uninstalled it, but I get this error every time I open ...
0
votes
1
answer
619
views
Possible to replace string if match string in two files? [closed]
i am aware of this doable by sed but only limited to one string
let me explain let better, lets say in file 1 we got something like this
tom,123456789
steve,1478321
jon,315457
and in the second file ...
1
vote
1
answer
9k
views
Runnning a python script on a socket with ncat?
I want to make a python script run on a socket of server in LAN. I wrote a number guessing script and i want to make it run on socket for other clients to play with it by connecting to port (say 1234)....
3
votes
1
answer
2k
views
how to invoke awscli from pip install?
Having installed the AWS CLI with pip install --user awscli what's the syntaxt to invoke awscli? It's listed here:
thufir@doge:~$
thufir@doge:~$ pip list
DEPRECATION: The default format will switch ...
20
votes
2
answers
212k
views
How can I run a python script using Anaconda from the command line?
Note: I'm new to Python and I've never really used external modules like the ones listed below so feel free to let me know if there's anything I could be doing better in order to get my program up and ...
-2
votes
3
answers
1k
views
Shell scripting : want to login on some server, which are in same domain and execute command and exit
I have 10 unix servers, I want to log into them one by one, execute 4-5 lines of code, save the output and exit.
For Example: 10 serves:
Intially at xyz server
Login in server 1 --> execute 4-5 ...
2
votes
1
answer
2k
views
.profile is written in shell script — can I instead make my system understand that I want it to execute a Python script instead?
I get Python. I don't get shell script. I could learn shell script, but I would rather not if I can use Python in its place.
A good place for me to start would be the .profile script. Currently, for ...
2
votes
1
answer
2k
views
Python now thinks arguments are files: Broken emerge, pip, livestreamer and most tools using Python
For these commands (in both bash and fish):
sudo emerge eix
emerge eix
I get this error:
usage: emerge [-h] [--version] [input [input ...]]
emerge: error: argument input: can't open 'eix': [Errno 2]...
2
votes
0
answers
538
views
Why won't my python scripts run without the python command when moved from Windows to Linux? [duplicate]
I have some Python files that I wrote on my Windows PC and then sent over to a Linux machine using pscp. They work as intended on Windows, but when I try to execute them on the Linux machine, I always ...
1
vote
1
answer
34
views
Maintain the path in installable UnixAPI
I am developing an API in Unix environment for virtual machines. Most of the modules are developed in python. I have few questions on this.
Inside the API I am using absolute path like '/root/virtman/...
0
votes
1
answer
117
views
Make python module as an installable API
I am developing an API in Unix environment for virtual machines. Most of the modules are developed in python. I have few questions on this.
I want to make this as an installable API, I mean to ...
3
votes
2
answers
345
views
Basic steps to develop python API in Unix environment
I am developing an API in Unix environment for virtual machines. Most of the modules are developed in python. I have few questions on this.
I have the file extension as abc.py. I would like to make ...
2
votes
1
answer
3k
views
Unable to install SciPy
I need to use the module skimage, which calls the module SciPy (I need to find contours)
import numpy
from sys import argv
from PIL import Image
from skimage import measure
# Inicialization
...
2
votes
1
answer
2k
views
Safely convert unicode strings to printable characters
I have many HTML files containing mixed unicode strings like \303\243 and printable characters like %s. What I'd like to do is converting the unicode strings into printable characters in a safe way.
...
1
vote
2
answers
171
views
Start Repl/CLI in Background and Feed Commands
Lets say the python repl takes a long time to start up, is there a way to start it up in the background so I can create an alias and feed it commands like python-current "command to run".
15
votes
3
answers
68k
views
Running python script from terminal without .py extension
I want to call a python script script.py from the terminal by simply typing script. Is this possible? If so, how?
I know I can avoid typing python script.py by adding #!/usr/bin/env python to the top ...