2,626 reputation
516
bio website
location
age
visits member for 2 years, 6 months
seen Dec 12 at 18:45

Dec
11
comment Is there a simple way to find out the last line executed in a bash script?
You could also use set +x to show exactly what command is being parsed, command by command.
Dec
5
answered How to increase the size of Linux Partition (EXT4) without loosing data when the swap partition is exactly after it?
Dec
2
comment Ping Printer then Execute Command
What have you tried? You might look into something like for host in 10.0.0.1 10.0.0.2 10.0.0.2; do if nc -z ${host}; then /path/to/enable_script.sh ${host}; fi; done
Dec
2
comment Sendmail shell script not working
Have you tried adding logging to your script to see what's going on? Also, you might want to use explicit paths to the files (e. g. tw.txt that your script references, as cron has a different runtime environment than you do when running scripts manually. You could add set +x to the top of your script, and in the cron table direct stdout and stderr to /tmp/"${0}".log and /tmp/"${0}".err for perusal.
Dec
2
comment Use sed to print from the very first line until the line containing the last occurrence of a pattern?
Why do you not wish to use grep for this? grep fish /path/to/file
Dec
2
comment Bash scripting problem - compare two lists and create a third
comm is exactly the tool for this job.
Dec
2
answered BASH Program to remove files, Integer expression expected
Dec
2
revised vim disassembles my indentation
Altered examples to use `set` rather than the `se` shorthand for clarity.
Dec
1
comment Read output in `screen` from outside
Why not have the process that you're running log itself? Or if you want only, say, the last 20 lines of output, then /path/to/myscript.sh arg arg arg | tail -n20 > /path/to/process_log.txt
Nov
26
comment Using `case` to handle script arguments
Valid points all. I suppose I was concentrating more on the question of using case..esac to handle arguments at all. I too would be more inclined to use the functional route if I were authoring such a script.
Nov
26
revised Using `case` to handle script arguments
fix recursion bug
Nov
26
comment Using `case` to handle script arguments
Oh, of course. It should call -unmount and then -mount, not -remount. That fixes that problem.
Nov
25
comment Programmatically get CPUs 'detailed' usage, like top/htop
You could poke around in /proc/, or use ps to see the raw information that top chews on, and parse it as you like.
Nov
25
comment LAMP CentOS page/folder Outbound Inbound bandwidth monitor
Is your host or your firewall blocking that port?
Nov
25
comment LAMP CentOS page/folder Outbound Inbound bandwidth monitor
It appears to only be listing on 127.0.0.1; if you're trying to get at it remotely, edit the ntop.conf file to have it listen on all interfaces, or a specific IP address.
Nov
25
comment LAMP CentOS page/folder Outbound Inbound bandwidth monitor
ntop is a service that provides a web interface that allows you to analyse all the network traffic your computer sees or is a party to. See luca.ntop.org/download/ntop-users-guide/ntop_Users_Guide_2.3.pdf or www.ntop.org/ntop/mini-tutorial-fresh-install-of-ntopng-on-centos-7/
Nov
25
reviewed Approve Writing a script that outputs local users and their password expiration date
Nov
25
comment LAMP CentOS page/folder Outbound Inbound bandwidth monitor
You could look into installing ntop and watching where your outbound connections are using your bandwidth, or you can use netstat to see current connections. I'd also look at your process tree and the output of lsof to see what files are open; it's possible your system was compromised.
Nov
25
comment Using `case` to handle script arguments
I'm pleased to be able to assist!
Nov
25
comment Using `case` to handle script arguments
$0 is the zeroth paramater to a script or function; in this case, the invocation of the script itself. If I invoke a script with ./script foo bar; $0 is "./script", $1 is "foo", and $2 is "bar".