Another C-Shell question

The geek forum. PHP, Perl, HTML, hardware questions etc.. it's all in here. Got a techie question? We'll sort you out. Ask your questions or post a link to your own site here!

Another C-Shell question

Postby frwl » Tue Apr 25, 2006 12:54 pm

I have to write a C-shell script for homework tonight, and I'm having some problems.

See, I have to make use of a `ls -1R ~` command. This should display each file and directory in my account on a new line.

However, my account looks something like this...

~/[files]
~/[directories with files]
~/backup/[backups of all my dirs and files]
~/backup/backup/[?]

this strange ~/backup/backup directory is driving me nuts. I can't look inside of it or do anything with it without getting errors (Error: /afs/sfsu.edu/mail2/nbyrd/backup/backup: Number of symbolic links encountered during path name traversal exceeds MAXSYMLINKS). And if a cshell script hits an error in execution, it bombs out and doesn't execute the rest of the script. Thus, when that ls -1R command is reached in my script, the whole thing comes to a full-stop because of that error.

Now, there's nothing I can do about the error; it's set in stone by the system admins to keep people from crashing the processor (which has happened in the past). I don't really keep any valuable information on the school server in my account, so I thought I'd try deleting everything inside the ~/backup/ folder... turns out I'm not allowed to do that.

So my last resort is trying to find a way around the backup directory with the ls command. However... I don't know of any way to make ls simply "ignore" or "skip" over directories when the Recursive option is flipped on. Any help?

Edit: Hahaha, this backup\backup even has grep trippin...
Code: Select all
libra% ls -1R | sort | cut -f1 -d':' | grep '^\..*' | grep -v '.*backup.*'
./backup/backup: Number of symbolic links encountered during path name traversal exceeds MAXSYMLINKS
./Mail
./bin
./cstuff
./homework/csc212/temp/paint
./homework/csc212/temp
./homework/csc212
./homework
./mail
./private
./public_html
./student/physics/lab
./student/physics
./student/prgm
./student
./temp
.

Grasping for straws now, eh?

Edit2: lol, figured it out.. but there has to be an easier way...
Code: Select all
ls -1R >& junkfile
foreach vari (`sort junkfile | cut -f1 -d':' | grep '^\..*' | grep -v '.*backup.
*'` )
    (etc etc etc)
end
rm junkfile
User avatar
frwl
 
Posts: 18
Joined: Fri Mar 24, 2006 12:00 pm

Postby Mithrandir » Tue Apr 25, 2006 6:09 pm

Your second backup is probably a sybolic link to the main backup file. cd to the first backup directory and do:
Code: Select all
ls -al

to find out what kind of file it is. You might be able to just delete it. My guess is you were playing around with synbolic links and accidentally created a loop.
User avatar
Mithrandir
 
Posts: 11071
Joined: Fri Jun 27, 2003 12:00 pm
Location: You will be baked. And then there will be cake.

Postby Slater » Tue Apr 25, 2006 10:41 pm

nope. I e-mailed the teacher and he just responede back, acknowledging that only system admins can touch those files/directories and that it's a major problem for students doing this assignment. Says that the only way to do it is the way I did it...

btw, ls commands on backup/backup return error too. like I said, I can't do anything with that directory... can't look at it, can't delete it, can't access it. Apparently it is a loop caused by a bug in the backup program that runs twice a week.
Image
User avatar
Slater
 
Posts: 2671
Joined: Sat May 22, 2004 10:00 am
Location: Pacifica, Caliphornia

Postby Mithrandir » Wed Apr 26, 2006 2:00 pm

I recommnend fireing the System Administrator. That should NEVER happen. Then again, I'm pedantic about the environment I create for my users. ;)
User avatar
Mithrandir
 
Posts: 11071
Joined: Fri Jun 27, 2003 12:00 pm
Location: You will be baked. And then there will be cake.


Return to Computing and Links

Who is online

Users browsing this forum: No registered users and 197 guests