|
What is the difference between executing a bash script like A and sourcing a bash script like B?
A >./myscript B >source myscript
Started by Scottie T on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Execution starts....
Sourcing is essentially the same as typing each line of the script in at the command prompt one at a time...
So if you have configs or function environment.
Sourcing you get all the extra variables defined in the script.
|
|
I have 1 bash script that runs another bash script, however the first bashscript isn't waiting for the second one to complete before proceeding, how can I force it to wait?
For example:
#!/bin/bash # first.sh #call to secondary script sh second.sh echo...
Started by BassKozz on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Check the ....
Are you sure that the other script isn't running problem with your script.
Make sureNormally it does; something else is happening.
Flag ( bash -x first.sh ) to see exactly what commands your script is executing.
|
|
I have a Cygwin bash script that I need to watch and terminate under certain conditions - specifically, after a certain file has been created. I'm having difficulty figuring out how exactly to terminate the script with the same level of completeness that...
Started by Barry Kelly on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
The script doesn't work unmodified under Cygwin, so I rewrote it, and with a couple more options....
This script looks like it'll do the job:
#!/bin/bash # Author: Sunil Alankar ## # recursive kill, albeit not without some minor caveats.
|
Ask your Facebook Friends
|
How can I determine the name of the bash script file inside the script itself?
Like if my script is in file runme.sh, than how would I make it to display "You are running runme.sh" message without hardcodding that?
Thanks,
Started by Ma99uS on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
Echo "You are running $0"
You can use $0 to determine your script name (with full path) - to get the script name only you can trim that variable with
basename $0
If the script name has spaces they state but there is a still ....
|
|
I need to change the server date by running a bash script called by php. When i invoke the bash script from shell it works, but if i call it via php then it doesn't work. The bash script is run as root.
php script code:
<?php $time = $_POST['input_...
Started by Tutul on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at serverfault):
If you run a script as root, it will run as the root user unless you use some commands to make running the PHP script from the command-line as root or through a web interface? When you access the PHP script via a web browser, that....
|
|
I'm trying to write a bash script (in Ubuntu) that will backup a directory using tar.
How can I do a check in the script so that it can only be run as root (or with sudo)?
For instance, if a user runs the script, it should say that this script must be...
Started by Cory Plastek on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at serverfault):
What is your objective here, to inform the user that they should run the script as root to stop a user from copying the script, taking....
To pull the effective uid use this command:
id -u
If the result is ‘0’ then the script is either.
|
|
I'm writing a script in Bash to test some code. However, it seems silly to run the tests if compiling the code fails in the first place, in which case I'll just abort the tests.
Is there a way I can do this without wrapping the entire script inside of...
Started by samoz on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Use set -e
#!/bin/bash set -e /bin/command-that-fails /bin....
To check the return status of every single command, your script would look like this:
#!/bin/bash # I'mTry this statement:
exit 0
Replace 0 with appropriate error codes.
|
|
Hello
I have just migrated to a UNIX workstation. My memory of Bash shell scripts has faded since school and I find the syntax to be highly confusing. I am wondering what other scripting languages are used to automate tasks. The two most popular ones ...
Started by Scott Davies on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at serverfault):
Beyond that, perl and python are popular these days; I'm different tasks:
Bash....
Just guessing though, dunno if anyone has done from scratch, it's probably best to (re-)learn bash.
That bash is most widely used, probably followed by perl.
|
|
How do I get the path of the directory in which a bash script is located FROM that bash script.
For instance, lets say I want to use a bash script as a launcher for another application. I want to change working directory to the one where the bash script...
Started by Jim Robert on
, 19 posts
by 19 people.
Answer Snippets (Read the full thread at stackoverflow):
`pwd`
(remember the backtics) will get you the current directory from within your bash script=
This is linux specific....
And not where you run the script from:
#!/bin/bash $orpath = 'set original path'; $path = `pwd`; if [ $path.
|
|
Okay, so I'm learning Bash, and there's that exercise;
"Write a script that checks every ten seconds if the user 'user000' is logged in."
My idea is to grep a who , but I don't know how to incorporate this into a script. I tried things like
if [ `who ...
Started by geord on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
This uses $? - a Shell variable which stores the return... .
If [ "$?" -eq "0" ] then ...
Mine does not.
You can do
who | grep "user000" > /dev/null 2>&1 # You can use "-q" option of grep instead of redirecting to /dev/null # if your grep support it .
|