I need to automate the execution of a shell script (ant, java, etc) or even through another shell script
The prompting for username/password is during script runtime
Related
I am running my application from the custom shell. we have set DefaultReturnCodeAction to Restart shell.
If there any way to run script when shell exits instead of restart shell.
I've been writing Bash scripts that work with a database lately.
To access the database, I need to ssh into a DiskStation (requires password) and then sudo a docker command (requires password) to access the container that the database is in. Only then can I execute and test out my scripts.
I wrote an expect script that automates this process and I want to embed it in my Bash scripts, but the only problem is the shell closes as soon as the expect script finishes executing.
Does anybody know how to work around this? I attached a photo with specific info removed. Bash script with embedded expect script
I know that execute a command and add & to the end would create a job and make the command execute in background.
Now I want to create a job in a bash shell. I tried
#!/bin/bash
my-job &
# some other tasks
Then I executed jobs, but I got no output. However, ps aux does show my-job is running in the background.
I want to create a job inside a script, because in some cases I want to bring the job into foreground.
jobs are usually an interactive shell concept, as there is usually a controlling terminal involved.
A shell script is executed in a non-interactive, non-login session of shell, hence no job control by default.
You can force job control inside a script, by setting:
set -m
inside the script.
From help set:
-m Job control is enabled.
Can I create a slack bot or a custom command to run a bash command or script from slack?
You can use Slack Remote Terminal to run a bash command or script (; separated) from slack, also you will get alerts about large tasks.
You can't execute a bash command or script directly from a Slack integration, but you could do so indirectly. For example, you could create a slash command that executes a command URL on a host that you control. When that command URL is executed, your host can then run whatever commands or sequences you want on that host.
But it would be very difficult, but not necessarily impossible, to ultimately execute a script on your local machine.
I have a Cocoa Application that is using NSTask to run a shell script that receives variables upon task launch. These variables are dynamic, and the command that is run will vary based on these variables. (they are flags, directory paths, etc) The command is rsync and it HAS to be run with sudo because it is interacting with files that the current user will not have ownership of.
My question is this: How do I prompt the user for an Administrator username and password when the script would normally prompt for them if run in terminal? I CANNOT use a variable to store the password.
Is there some sort of way to use an input pipe? If so, how does NSTask know when to prompt for the username and password, and how would you send input through the input pipe to the script without using a variable?