Hello,
If I create the script /root/bin/whoami.sh conatining:
#!/bin/bash
whoami
And this script is called by a user with a properly configured sudo, it will indicate
root
Is there a fast way to obtain the actual user in a script, or will I have to resort to parameters passing along this username?
TIA,
Bert
...
The title says it all but I want to be able to specify the location in both where to scan and where the converted file will go.
It's just there is a lot of conversions and I've got a script which should sort it for me.
Currently I've tried
convert -resize 300x300 > /media/usbdisk1/development/ephoto/richard/images/gallery/2007/29/norm...
I am rsync'ing a a folder from one host to another, I am then zipping the mirrored folder so that it can be transferred to tape.
Now, when I zip the folder (bearing in mind that the folder is ~300GB) using the below script it keeps the files which have been deleted from the directory that I am zipping.
zip -ru /home/rsync/www.zip /home...
I'd like to be able to put log messages in the middle of bash functions, without affecting the output of those very functions. For example, consider the following functions log() and get_animals():
# print a log a message
log ()
{
echo "Log message: $1"
}
get_animals()
{
log "Fetching animals"
echo "cat dog mouse"
}
value...
Hi,
I wrote init.d script that suppose to run java CLI proccess.
The problem is that when i stop it, i get [failed] and the proccess is still running.
thanks
#!/usr/bin/env bash
#
# chkconfig: 345 97 03
#
# processname: quotes-srv
#
#
# source function library
. /etc/rc.d/init.d/functions
NAME=quotes-srv
start() {
echo -n ...
I make a clj script for running clojure as follows.
java -cp $CLOJURE_JAR:$CLASSPATH clojure.main $1
The problem is that $1 is the name of the script, so I can't pass the argument with this.
The alternatives can be
java -cp $CLOJURE_JAR:$CLASSPATH clojure.main $1 $2 $3 $4 $5
hoping that the number of arguments is less than four, ...
I've created several bash aliases in Git Bash on Windows, to launch executables from the bash shell.
The problem I am having is that is seems the bash is waiting for an exit code before it starts responding to input again, as once I close the app it launched, it starts taking commands again.
Is there a switch or something I can include...
I have a string like first url, second url, third url and would like to extract only the url after the word second in the OS X Terminal (only the first occurrence). How can I do it?
In my favorite editor I used the regex /second (url)/ and used $1 to extract it, I just don't know how to do it in the Terminal.
Keep in mind that url is a...
Using Git Bash on Windows, if I create a bash script, where do I put it so that I can access it from the bash shell?
Basically, I want to create a bash shell script that does some stuff with files etc.
I want to invoke the function from inside the bash with some parameters, and the script will then do its work.
I am completely new to ...
I want to run a script once day (and only on weekends), however, I cannot use cron job for that.
I was thinking about having an infinite while loop, sleep for 24 hours, check if it is a weekend, and if so execute the script.
What it's a good solution under bash on linux?
my current implementation:
#! /bin/bash
while [ true ]; do
...
Hello everyone!
So my question is how can I pass a file argument to my bash script using a Terminal command in Linux?
At the moment I'm trying to make a program in bash that can take a file argument from the Terminal and use it as a variable in my program. For example I run
myprogram --file=/path/to/file in Terminal.
My Program
#!/bin...
If I do a
sudo netstat -tup | awk '{print $5}' | sort | uniq -c | sort -n
I can get a list and count of how many connections I have to each host. But how can I tell how many times I've been connecting to that host ever minute/hour/day? Is there a TCP log somewhere that I can grep through to see how and when I'm connecting to what?
I...
ok i know this is stupid but atleast im trying :)
$result = shell_exec('C:/cygwin/bin/bash.exe /c --login -i git');
var_dump($result);
somehow i cant get git command from cygwin, anyone ?
Adam Ramadhan
edit*
it should give
usage: git [--version]
[--exec-path[=GIT_EXEC_PATH]]
[--html-path]
[-p|--paginate|--no-p...
I have a log file with format
id operation
id success message
The second id is same as the first, but if only the the operation is successful. How can I get these two lines from the log to a new file?
...
I have a bash file that does some file manipulation. I don't want to have to open the terminal every time I run it. Is there a way to make the program run when I double click it? (Like a windows .exe file)
Thanks
...
I have a bunch of folders and subfolders. Each one contains, amongst other things, a text file called index.yml with useful data. I want to search through all of the different index.yml files to find instances of a search string. I must be able to see a few lines of context and the directory of the index.yml file that was found.
This...
I have a folder with files named as
input (1).txt
input (2).txt
input (3).txt
...
input (207).txt
How do I rename them to
input_1.in
input_2.in
input_3.in
...
input_207.in
I am trying this
for f in *.txt ; do mv $f `echo $f | sed -e 's/input\ (\(\d*\))\.txt/input_\1.in/'` ; done
But it gives me
mv: target `(100).txt' is not a d...
$ cat weirdo
Lunch now?
$ cat weirdo | grep Lunch
$ vi weirdo
^@L^@u^@n^@c^@h^@ ^@n^@o^@w^@?^@
I have some files that contain text with some non-printing characters like ^@ which cause my greps to fail (as above).
How can I get my grep work? Is there some way that does not require altering the files?
...
Stumbled across the ∴ operator in some of the rvm install scripts and couldn't seem to locate information on what it does? Is there documentation on this somewhere?
...
I have been struggling to get my CakePHP site working on a Godaddy "grid hosting" account. My cake app is setup is hosted from a subdirectory on the account, and can be accessed via a subdomain. I had to adjust my .htaccess files to get this working, and now I need to get the CakePHP console working in this environment.
I have the same ...