Questions tagged [interactive]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
17
votes
6answers
20k views

Run script in a non interactive shell?

I have a cron job that is running a script. When I run the script via an interactive shell (ssh'ed to bash) it works fine. When the script runs by itself via cron it fails. My guess is that it is ...
11
votes
3answers
2k views

How to do a text replacement in a big folder hierarchy?

I want to search and replace some text in a large set of files excluding some instances. For each line, I want a prompt asking me if I need to replace that line or not. Something similar to vim's :%s/...
11
votes
1answer
601 views

Displaying usage comments in functions intended to be used interactively

I have a number of functions defined in my .bashrc, intented to be used interactively in a terminal. I generally preceded them with a comment describing its intended usage: # Usage: foo [bar] # Foo'...
10
votes
8answers
6k views

How can I disable the new history feature in Python 3.4?

Since upgrading to Python 3.4, all interactive commands are logged to ~/.python_history. I don't want Python to create or write to this file. Creating a symlink to /dev/null does not work, Python ...
10
votes
2answers
4k views

How to read user input when using script in pipe

General problem I want to write a script that interacts with the user even though it is in the middle of a chain of pipes. Concrete example Concretely, it takes a file or stdin, displays lines (...
9
votes
3answers
7k views

Invoke a command/script disconnected from the controlling terminal?

I'm investigating the behaviour of a script that is normally run as an automated process (e.g. cron, Jenkins). The script can (eventually) invoke commands that behave differently (seeking user input) ...
7
votes
1answer
3k views

How would I detect a non-login shell? (In Zsh)

I want to create a script that runs when a Zsh instance starts, but only if the instance is: Non-login. Interactive I think I'm right to say .zshrc runs for all interactive shell instances, ....
6
votes
2answers
463 views

Is possible to define a bash script to run interactively by default?

I have written some scripts and stored them in my ~/bin folder. I'm already able to run them just by calling their title during a shell session. However, they aren't running interactively (I mean, my ~...
5
votes
1answer
166 views

Why does bash treat commandlines starting with dots specially? [duplicate]

I tried searching online for an answer, but the answer (if exists) is overshadowed by other applications of dot in shell scripting. So here goes. EDIT: Turns out it's related to Fedora's default ...
4
votes
1answer
2k views

Prompt for confirmation for every command

I'm writing a pretty ad-hoc install script for some thing. No much control constructs, basically just a list of commands. I'd like the user to confirm each command before it gets executed. Is there a ...
4
votes
2answers
16k views

ssh command and non-interactive, non-login shell

There is a sentence in the post below. Difference between Login Shell and Non-Login Shell? The focus is here: Another way to get a non-interactive login shell is to log in remotely with a command ...
3
votes
2answers
1k views

Copying files interactively: “cp: overwrite”

I'm trying to figure out what words does the -interactive option of cp accepts as input. For your convenience, here's code that sets up files for experimentation. touch example_file{1..3} mkdir ...
3
votes
3answers
1k views

How can I make rm -rf ask for confirmation just once at the directory level?

If I use rm -rfi, this asks me every time each file is deleted. If I have a list of rm -rf commands, how can I make it so that the machine asks me for confirmation just once (when trying to delete the ...
3
votes
1answer
557 views

Supress startup messages on stdout?

I'm using tcsh, and have to source a group .cshrc file. This file echoes some messages, which is fine for normal shells, but causes problems with programs like scp and rsync. I can see the solution ...
3
votes
1answer
188 views

On OS X, how do I log in interactively as root starting from my normal user account?

I have been doing this for a while: sudo su - but it uses 'sh' rather than 'bash', which is what I'd like to do. Which command will log me in as root and get me a bash shell even if that's not the ...
3
votes
1answer
245 views

PHP interactive script that calls nano

I have written simple PHP programs meant for the command line that run a script to completion with the hashbang at the top: #!/usr/bin/php -q <?php //etc However I need to write a script that ...
2
votes
1answer
333 views

Why is Linux allowed to become unresponsive? [closed]

This question Why can a system become unresponsive? comes close. The answer kind of explains what is likely happening, but I just don't understand why this problem hasn't been solved since at least ...
2
votes
1answer
3k views

Count deleted files with interactive rm (rm -i)

I want to count number of interactively removed files and directories: for f in /tmp/mydir/* ; do rm -ir "$f" done How to do it in most concise/elegant way? Example: abc@def:/tmp/mydir$ tree . ├─...
2
votes
2answers
10k views

For loop for renaming files with prompt for each filename

I have to convert multiple video files in a folder. I have to rename each one of them but I need the script to prompt me to write a custom name for each filename. Here is what I've got so far: First ...
2
votes
2answers
1k views

Which file is loaded and executed by a non-interactive non-login shell?

A non-login interactive shell (for example: when I open a Terminal window in Ubuntu) loads and executes the file ~/.bashrc. Now when I execute a shell script, a non-interactive non-login shell ...
2
votes
2answers
562 views

Non-ascii chars are no longer displayed in bash

Updated: This is not a file system problem. I used to be able to enter: $ echo kødpålæg But now bash/zsh change this to: bash$ echo kddddddddplg zsh$ echo k<c3><b8>dp<c3><a5&...
2
votes
2answers
2k views

Interactive multiple choice in a bash script

Is there a simple way to let the user interactively choose one of the lines of the output of lsblk -f? NAME FSTYPE LABEL MOUNTPOINT sda ├─sda1 ntfs WINRE_DRV ...
2
votes
1answer
1k views

Zsh clear scrollback buffer

With Bash CtrlL will clear the screen but not scrollback buffer. In the past I have worked around this by using: tput reset However I have noticed that this command will not clear the scrollback ...
2
votes
1answer
360 views

How to trap INT signal infinitely many times?

I'm piping output of an interactive command (ghci) through sed-based script to add some colors: ghci | colorize.sh where colorize.sh is something like: #!/bin/bash trap '' INT sed '...some pattern.....
2
votes
1answer
816 views

how to pass value for interactive jar file in shell script

We are using oswatcher in our environment which runs and collects diagnostic information on Redhat linux 5.6 /6.4 versions. This is scheduled under root which runs and collects information on iostat,...
2
votes
1answer
733 views

Non-interactive & non-login shell environment?

I'm trying to understand non-interactive & non-login shells and having a hard time conceptualize the process a non-interactive & non-login shell goes through to start up. The way I ...
2
votes
0answers
227 views

Prevent scp and less commands reading interactive tcsh script

I'm using tsch through PuTTY, and let's start by this: please don't try to convince me to migrate to another shell...:) It's being a long time that commands like scp and less didn't work well for me. ...
2
votes
0answers
1k views

Recording shell output for interactive commands

While looking into a shell redirection problem, I found a couple of answers that pointed me to the script command. As I understand it, script just records in- and output of the terminal, and allows me ...
2
votes
1answer
293 views

tool in terminal like helm-occur/helm-swoop for terminal?

I don't know whether this is the right place to post this question, but if you are not an Emacs user, I'll explain the basic usage of helm-occur/helm-swoop. I like helm-occur/helm-swoop for Emacs ...
1
vote
2answers
3k views

How to choose a response for interactive prompt during installation from a shell script

I am writing a shell script to install all my required applications on my Ubuntu PC in one shot (while I can take a stroll or do something else). For most applications adding -y to the end of the apt-...
1
vote
2answers
1k views

Why no such non-interactive version of bashrc?

From what I understanding, a daemon is a background process, but daemon requires unique config file to set the environment variable. E.g. Hadoop daemon require hadoop-env.sh to set environment ...
1
vote
1answer
1k views

interactive SMTP command using telnet via a shell script

I'm trying to access a SMTP remote server thru a remote shell using telnet and a command file command.txt containing command to send to that SMTP server as seen on https://tecadmin.net/ways-to-send-...
1
vote
1answer
779 views

Making mysql CLI ask me for a password interactively

I use the following code as part of a much larger script: mysql -u root -p << MYSQL create user '${DOMAIN}'@'localhost' identified by '${DOMAIN}'; create database ${DOMAIN}; GRANT ...
1
vote
2answers
67 views

sh: is there a command to interactively edit the PWD?

I'm looking for a command that invokes readline or similar, primed with the current $PWD, to let the user edit the current directory, then cd to the edited value. E.g. > cd ~/a/b/c/d > pwd > ...
1
vote
1answer
369 views

Bourne shell: what does it execute on interactive, non-login?

I ask in that way, because according to https://unix.stackexchange.com/a/46856/84749, when I start screen it's an "interactive, non-login" I'm doing. What's actually happening is I'm logging into a ...
1
vote
2answers
66 views

Distinguish between command that typed by human and run by script

For example $ pwd /home/my_name It is possible or not to identify that this command is typed by human or run by script.
1
vote
1answer
54 views

Confused about determining if a shell script is running interactively

I only want to determine from my POSIX shell script, if it is running interactively, but for some reason, the following function: running_interactively() { printf '%s' ${-} | grep -F i > /dev/...
1
vote
1answer
423 views

rm -iR does not work inside a loop

Here is my loop ls -ltrd * | head -n -3 | awk '{print $NF}' | while read y; do rm -iR $y done output: rm: descend into directory oct_temp17? rm: descend into directory oct_temp18? rm: ...
1
vote
2answers
4k views

How to override option in aliased command? [duplicate]

I have a rm aliased: alias rm='rm -i' How can I override the -i option when I want to remove a large number of files and I don't want to confirm each deletion?
1
vote
1answer
56 views

Type Y to Delete, if the script is being executed manually

This is a 2 part question. Scenario: This script is on a cronjob. If a folder does not exist, the system sends us an email that opens a ticket which notifies us that the folder is not available. We ...
1
vote
1answer
586 views

Confused about the meaning of an interactive and non-interactive shell when running a script

I have read the following in this question: A shell running a script is always a non-interactive shell, but the script can emulate an interactive shell by prompting the user to input values. I ...
1
vote
1answer
494 views

Setting environment variables by prompt instead of in command line

Is there a way for setting an environment variable in bash such that its value is not passed directly after = but is prompted for separately? For example, something akin to $ TEST=< (syntax does ...
1
vote
1answer
356 views

Python3 not coming up in interactive mode

I have python3 installed on a work computer. Python 3.4.3 (default, May 3 2016, 09:46:33) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux Type "help", "copyright", "credits" or "license" for more ...
1
vote
1answer
399 views

Opening interactive python shell after running python script in background

python3 -i test.py opens an interactive python shell after running test.py. However, if I try to run it in the background with python3 -i test.py & the job stops automatically with a ^C and shows ...
1
vote
0answers
80 views

merge commands for line-by-line interactive merging with sdiff, in MacOS unix. Is there a working version?

On MacOS, the sdiff command is described as able to do line-by-line interactive merging, and lists several merge commands for the latest chunk. e.g. sdiff -o mergefile fileleft fileright The single ...
1
vote
0answers
3k views

Bash script calls python script that wants interactively input ( not only arguments )

I have a bash script bash.sh that looks like this: #!/usr/bin/env bash /usr/local/sbin/pythonScript.py firstArgument secondArgument If I call the pythonScript.py from my terminal with the two ...
1
vote
1answer
1k views

How to determine if script is called by interactive shell or another script?

It's fairly straightforward to determine from within a script that the code being run is not running in an interactive shell, but you already know that as you write the script, so I'm not sure how it'...
1
vote
0answers
15 views

Configuring an alert when a program tries to interact with the user

Most programs in *nix-land take their options via the command line or through a configuration file. However, there are a few programs that do not have any such option, and will resort to interacting ...
1
vote
0answers
404 views

UDEV-rule:Open new gnome-terminal window on usb-plugin AND activate it for stdin/stdout/stderr?

My attempt is this: If a certain USB-device is plugged in, I want to open a gnome-terminal window in my desktop-environment. This newly opened window must be able to be interactive, this means, the ...
1
vote
2answers
1k views

Interactive commands with pipe and grep

As you know, there are commands such as top, watch, Airodump-ng, etc, that whenever you run, everything on the terminal change all the time. what I want to do is that run one of theses interactive ...