![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 630
Rep Power: 4
![]() |
Strange problem with redirection
I'm very new to all this, so I'm sure it's something obvious.
There's a program that is packaged with Archlinux called rankmirrors that takes a repository mirror list (in /etc/pacman.d) and returns a list of sorted mirrors based on speed. I glanced at a BASH scrpting tutorial and came up with this: #!/bin/bash
# Rank all mirrors and save changes to
# files. Uses the rankmirrors script bundled with
# Pacman 3
# By Jesse H-K
# 2007 - 04 - 09 (April 9th)
root_uid=0
mirror_dir=/etc/pacman.d
rankmirror_script=/usr/bin/rankmirrors
if [ $UID != $root_uid ]; then
echo "Please run this script as root."
exit 1
elif [ ! -d $mirror_dir ]; then
echo "$mirror_dir not found!"
exit 1
elif [ ! -e rankmirror_script ]; then
echo "Unable to find rankmirrors script!"
exit 1
fi
cd $mirror_dir
mirror_files=`ls`
for mirror in $mirror_files; do
# replace the old file with the output
# rankmirros.
rankmirrors $mirror > $mirror
done
exit 0Where the /etc/pacman.d consists of the files: $ ls /etc/pacman.d community current extra release testing unstable For some reason, the script deletes all the mirrors in each file and leaves an empty file with the header "Mirror file generated by rankmirrors on $date" where $date is obviously the date. However, when I run rankmirrors on a script and redirect the output to a differently named file like so: $ rankmirrors current > current.new Everything works normally. What am I doing wrong?
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Strange getMonth/setMonth problem | aaroncampbell | JavaScript and Client-Side Browser Scripting | 4 | Oct 31st, 2006 2:49 PM |
| strange problem | brad sue | C++ | 3 | Sep 1st, 2006 8:50 AM |
| Strange Problem? | magic_e | PHP | 10 | Feb 9th, 2006 8:54 PM |
| cgi/perl script + IE problem | joyceshee | Perl | 2 | Jan 24th, 2006 11:10 AM |
| string problem when passing in linked list | quantz | C++ | 0 | Feb 27th, 2005 10:11 AM |