I'm trying to download an html file with curl in bash. Like this site:
http://www.registrar.ucla.edu/schedule/detselect.aspx?termsel=10S&subareasel=PHYSICS&idxcrs=0001B+++
When I download it manually, it works fine. However, when i try and run my script through crontab, the output html file is very small and just says "Object ...
Let's imagine I have a bash script, where I call this:
bash -c "some_command"
do something with code of some_command here
Is it possible to obtain the code of some_command? I'm not executing some_command directly in the shell running the script because I don't want to alter it's environment.
...
Hi,
I need to generate a random port number between 2000-65000 from a shell script. The problem is $RANDOM is only a 16bit number, so im stuck!
PORT=$(($RANDOM%63000+2001)) would work nicely if it wasn't for the size limitation.
Does anyone have an example of how I can do this, maybe by extracting something from /dev/urandom and getti...
I'm trying to write a script that uses the make command, but Mac os 10.5 doesn't come with make installed by default, and when you download the make source code from gnu's website, you have to use make itself to compile and install it. which is hard if you don't have it in the first place. How can I install make?
(I know you can get make...
I'm writing a bunch of Linux shell scripts with complex selections. For now I use zenity for prompts. I'd rather use something where I can show more than one UI element at a time and query it in a script (e.g. a list and some checkboxed and a file picker and an entry field.
What are my options?
...
i have a script like that
genhash --use-ssl -s $IP -p 443 --url $URL | grep MD5 | grep -c $MD5
i want to get stream generated by genhash in a variable, how do i redirect it into a variable $hash to compare inside a conditional
if [ $hash -ne 0 ]
then echo KO
exit 0
else echo -n OK
exit 0
fi
...
HI there!
I've run into some problem while learning to combine .sh files and PHP. I've create a file test.sh and in that file I call a PHP file called test.php.
If I double click on the .sh file then it runs perfectly but when I try to run it from the terminal I get "command not found". I'm in the exact folder as my .sh file but it won...
I'm trying to recover a mates hard drive, there is no structure what so ever so music and images are everywhere but in named folders sometimes >5 folders deep, I've managed to write a one-liner that finds the files and copies them to a mounted drive but it preserves the file structure completely. What I'm after is a bit of code that sear...
I have roughly 12 computers that each have the same script on them. This script merely pings all the other machines, and prints out whether the machine is "reachable" or "unreachable". However, it is inefficient to login to each machine manually using ssh to execute this script.
Suppose I'm logged into node 1. Is there any way to for m...
I have an xml file that I want to configure using a bash script. For example if I had this xml:
<a>
<b>
<bb>
<yyy>
Bla
</yyy>
</bb>
</b>
<c>
<cc>
Something
</cc>
</c>
<d>
bla
</d>
</a>
(confidential info removed)
I would like to write a bash script that will rem...
I would like to run a backup job on a directory tree from a bash script if any of the files have been modified in the last 30 minutes. I think I can hack together something using find with the -ctime flag, but I'm sure there is a standard way to examine a directory for changes.
I know that I can inspect the ctime of the top level direct...
absolute="/foo/bar"
current="/foo/baz/foo"
# magic
relative="../../bar"
Can you help me with magic? (Hopefully not too complicated code...)
...
I have a bash script that uses growlnotify to send notifications. However, growlnotify doesn't work if Growl isn't already running, and it won't auto start Growl if it needs it, either. So I want to be able to check if Growl is running, and then start it if it isn't.
I'm thinking of doing something like:
g=$(ps -e | grep Growl | grep -v...
Hello, I have trouble using sed.
I need to replace some lines in very deprecated HTML sites which consist of many files.
My script does not work and I do not why. When I tried to find exact pattern with Netbeas it worked.
find . -type f -name "*.htm?" -exec sed -i -r 's/ing\. Šuhajda Dušan\, Mírová 767\, 518 01 Dobruška\, \+420 737 980 ...
Hi, is there something like API built atop the standard ProcessBuilder for calling system programs? I won't argue that scripts can be ported to Java but utilities like arping and netstat are good-to-go in Linux.
...
I'm trying to implement my own version of the 'cd' command that presents the user with a list of hard-coded directories to choose from, and the user has to enter a number corresponding to an entry in the list. The program, named my_cd.py for now, should then effectively 'cd' the user to the chosen directory. Example of how this should wo...
i want to have an alias "t" to enter a folder and list the content there.
i tried with:
alias t="cd $1; ls -la"
but it just listed the folder i typed but did not enter it. i wonder why?
cause when i use this one:
alias b="cd ..; ls"
it went back to the parent and listed the content.
so i want the "t" do enter the folder i type in...
I have text file with entries like
123
112
3333
44
2
How to add these numbers and get the sum of these.
...
So, I have a file called 'dummy' which contains the string:
"There is 100% packet loss at node 1".
I also have a small script that I want to use to grab the percentage from this file. The script is below.
result=`grep 'packet loss' dummy` |
awk '{ first=match($0,"[0-9]+%")
last=match($0," packet loss")
s=substr($0,fi...
xargs is widely used in shell scripting; it is usually easy to recast these uses in bash using while read -r; do ... done or while read -ar; do ... done loops.
When should xargs be preferred, and when should while-read loops be preferred?
...