Skip to main content

All Questions

3 votes
3 answers
815 views

Alternatives to file polling?

In the following code, I have to poll $tmp_input to continue executing the code because wezterm cli send-text is asynchronous. This makes sure that $tmp_input is ready. tmp_input=$(mktemp ./tmp_input....
wyc's user avatar
  • 143
1 vote
2 answers
2k views

How to run the command "sudo sh /path/to/script.sh" by double clicking?

I have a question from this thread How to run a bash script by double clicking by entering the path in sudoers?. Since it was explained to me that it is unsafe to grant sudo privileges to the script....
moninah's user avatar
  • 15
1 vote
1 answer
117 views

Shell scripts: How to copy past outputs of terminal emulator?

I want to make a shell script which copies the past outputs of the GUI terminal emulator (for example, last 20 lines). The motivation is as following: When I execute a procedure which requires long ...
user356126's user avatar
2 votes
2 answers
4k views

Command/script to start a terminal, enter text but don't execute (wait for text to be written, pasted, etc.)

I often write commands in the terminal that I don't know by heart, and then paste some path or file name from the clipboard, before pressing Enter. I thought that it would be fun to do the first ...
cipricus's user avatar
  • 1,629
0 votes
2 answers
45 views

Is there a way to interact with a shell but from an app or separate program?

I am trying to find a way to both receive the output of a shell and then return output, but from a different front end interface? I am trying to incorporate the Linux terminal into a potential ...
James Lindner's user avatar
0 votes
0 answers
574 views

Want the terminal output (stderr and stdout) of the previous command executed in terminal

I'm trying to store both stdout and stderr from the terminal (and if possible stdin given by user) in a file for every command. So I started creating a trap function to execute every command in an ...
Biswajit's user avatar
-1 votes
1 answer
122 views

Bash: weird parse output? [duplicate]

I'm working on a simple script that accepts multiple command line arguemnts in an order: #!/bin/bash function arg_parser () { while [[ $# != 0 ]] ; do case "$1" in --one) varone="$2" ...
user324071's user avatar
0 votes
0 answers
29 views

Executing a script directly vs. executing a script via the source command [duplicate]

I saw a question recently where a user wanted to ensure that his script is only executed by using source. My question is: what's the difference between ./test_script.sh and source test_script.sh? I ...
nagamani's user avatar
  • 181
0 votes
2 answers
3k views

Run/stop command in terminal without human interference?

As a beginner Linux user I'm facing with the little problem. I have 1 command in terminal like in the picture: When I run this command it will generate some lines, but the problem is I need to make ...
user avatar
14 votes
3 answers
43k views

How to display size "human-readable" in lsof | grep /var* [duplicate]

I am currently trying to see , all the files which are using /var mount. With lsof | grep /var* when Its displaying size in bytes. How can I display file size in MB. Thank you.
Raja G's user avatar
  • 6,007
3 votes
1 answer
7k views

How to Prompt the user to press Enter to Exit in terminal so that the terminal doesn't close automatically?

Here is my Port.sh file echo 'Give me a maximum of 5 seconds to run please.' lsof -i | grep Xvnc | grep ESTABLISHED | grep $USER lsof -i | grep $USER | grep Xvnc | grep -o -P '(?<=:).*(?=->)' ...
Belldandu's user avatar
  • 177
1 vote
1 answer
913 views

Run a script after some command were executed

I have a list of scripts ./myscript <param> | grep "asd" ./myotherscript <param> <param> > file ... How can I automaticaly run another script when one of these command in the ...
Wolfy's user avatar
  • 342
3 votes
1 answer
742 views

Conditionally killing a process based on its output

I have a REPL (read-eval-print-loop) for the Clojure programming language listening on a network socket. I can send it code over the network and the code will be evaluated and the answer sent back to ...
xyz's user avatar
  • 493