Tag Info

New answers tagged

4

In order to set the desired environment variables you need to source the .bash_profile file with . /home/some_user/.bash_profile. In your case, you are executing the bash_profile file, which will basically execute that file and exit the shell. The next time some_script is run it will start with fresh environment variables. Check this link - sourcing vs ...


3

You don't because your sed string doesn't have to be quoted, and in fact, on the remote server, it's not quoted. What's passed as argument to your ssh command looks like this: for user in $(/bin/ls -A1 /var/cpanel/users) ; do if grep -q RS=paper /var/cpanel/users/${user}; then sed -i s/^RS=paper_lantern$/RS=x3/ /var/cpanel/users/${user}; fi; done And it ...


0

less elegant than --init-file, but perhaps more instrumentable: fn(){ echo 'hello from exported function' } while read -a commands do eval ${commands[@]} done


7

I suspect that any performance increases you'll see are from improving whatever wrapper you're using to make your connections, rather than the overhead of launching curl for each URL. Whether it's curl or netcat or wget, you'll probably want to launch each one separately in order to process their results separately. But I'll answer this question in two ...


1

Maybe use Netcat? ( netcat $domain 80 | head -n 1 ) << EOF HEAD / HTTP/1.0 Host: $domain EOF Output: HTTP/1.1 200 OK


17

yum keeps its own history, so you can find out when a package was installed or updated using its history. For instance, yum history packages-info ruby will give you all the transactions involving ruby, where the oldest one is usually the one where the package was installed. Transaction ID : 102 Begin time : Thu Apr 3 17:15:17 2014 Package : ...


6

You can remove them with yum autoremove.


0

Here's another better answer which is a good compromise between performance and security. Feel free to test it. FILE=$1 SERVDEST=$2 SIZE=`du -h --apparent-size $FILE | cut -f1` DATE=`date +%Y%m%d%H%M` tar czv - $FILE | ssh $SERVDEST "cat - > /backup/backupSO/nc_$FILE.tgz" For even more performance, you can set theCompressionLevel (with -o) and use a ...


0

What you're doing is useless. You should use use scp. It's basicaly the command to send files over ssh. example: FILE=$1 SERVDEST=$2 SIZE=`du -h --apparent-size $FILE | cut -f1` DATE=`date +%Y%m%d%H%M` tar czv /tmp/tmpfile.tar.gz $FILE scp $FILE $SERVDEST:/backup/backupSO/nc_$FILE.tgz rm /tmp/tmpfile.tar.gz


1

Setting IFS the way you do is a fine way to split command output into elements. Then, using for to iterate over array elements is a perfect. I don't quite grok your code, but I wonder this this is easier to maintain: #!/bin/bash IFS=$'\n' ips=( $( ip a | sed -n '/\<inet\>/ { /127\.0\.0\.1/! s,.*inet \([^/]*\)/.*,\1,p }' ) ) hosts=( $( awk ' ...


0

You need two backgrounded tailboxes and a static component. Msgbox will do. dialog --begin 1 2 --tailboxbg a 10 70 --and-widget --begin 13 2 \ --tailboxbg b 10 70 --and-widget --keep-window --msgbox "Exit" 5 10


1

Look at the ssh manual, more specificaly the -t option. If this doesn't work, try the -tt option. Also, I think your get-traffic.sh script should exit 0 at the end.


0

"url" is a BASH variable within you audit script. In your case you should manually define it as the IP of your PXE server. That's it. If your PXE server is also your DHCP server then you can add some BASH script lines for automatically defining the variable value from the DHCP server IP address avoiding this way the needed manual definition.


0

not so much an answer but a tip, i always do rm (dir) -rf not rm -rf (dir) i.e: don't go nuclear until the last possible moment. It helps mitigate situations in which you fat finger the dir name in such a way that it's still a valid deletion, such as slipping and hitting the enter key.


0

Sadly, I cannot leave a comment above due to insufficient karma, but wanted to warn others that safe-rm is not a panacea for accidental mass-deletion nightmares. The following was tested in a Linux Mint 17.1 virtual machine (warning to those unfamiliar with these commands: DON'T DO THIS! Actually, even those familiar with these commands should/would ...


0

As stated in the Tomcat Doc the startup.shshould not be adjusted but a setenv.sh be created which is expected in the directory "bin" of your tomcat installation. There you can use the shell commands as usual.


0

On a Linux system hostname -i will give you only the IP address. On a Solaris system use: ifconfig e1000g0 | awk '/inet / {print $2}'


5

According to the section on "Parameter Expansion" in the bash man page, this means "use the default value if the parameter is unset." So for example, ${PID-/run/unicorn.pid} equals $PID if $PID is set, otherwise /run/unicorn.pid.


0

Naming a variable with a variable (vr$n=value) is not possible without an export. However, I suggest to use an array instead: vr[$n]=$(echo -e "$line" | awk '{print $'$n'}') and reference the value afterwards with a syntax like this: echo ${vr[$n]}


0

Stopping services like Samba, Apache, MySQL and did the trick. After stopping them, the connection didn't terminate and I was able to transfer 7GB tar file without any "corrupted mac on input" error. Log file you should tail to see the error is /var/log/sercure


0

Maybe I just figured it out? I added ngx.redirect("/"); So I have a / with location /public/html/ in my nginx.conf and also a: location /lua { default_type text/plain; content_by_lua ' os.execute("/myscript.sh") return ngx.redirect("/")'; I would have preferred to just one 'location' instead of using redirect like that but at least I ...


1

Just curl this page: $ curl wtfismyip.com/text


0

Pipe a "sed": script.sh | sed "s|^|$('date') :: |" >> /var/log/logfile


1

Using "rm -rf" has an inherent race condition, you could namely delete files that were just created between the rsync and the rm invocations. I prefer to use: rsync --remove-source-files -a server:incoming/ incoming/ && ssh server find incoming -type d -delete This will NOT remove the directories if they are not empty.


0

The bash variable $EUID shows the effective UID the script is running at, if you want to make sure the script runs as root, check wether $EUID contains the value 0 or not: if [ $EUID -ne 0 ]; then echo "$0 is not running as root. Aborting." exit 2 fi This is better than the solution with /usr/bin/id (for bash scripts!) because it doesn't require ...


0

You can use one option multiple times and collect results in the array: ./shell.sh -d db1 -d db2 Code: while getopts "d:" opt do case ${opt} in d) dbs+=("$OPTARG");; esac done


0

No. But you pass a single argument joined with, for example, a colon; or quoted ./shell.sh -d db1:db2 ./shell.sh -d "db1 db2" In the first case: while getopts d: opt; do case $opt in d) IFS=: read -a dbs <<< "$OPTARG" ;; esac done In the 2nd case (quoted) d) set -f # turn off filename expansion ...


1

You will need to set l1 and newip inside the for block if you want to update these values on each iteration. #!/bin/bash set -x osdir=$(find /nodeFolder -maxdepth 1 -type f | wc -l) lbdir=$(more /root/nodeFile.txt |wc -l) lait2=1 count=$(($lbdir-$osdir)) lait=1 if [ $osdir -eq $lbdir ] ; then echo " Nothing to do " else if [ $osdir -lt $lbdir ] ; then ...



Top 50 recent answers are included