image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old February 19th, 2004, 08:15 PM
Registered User
 
Join Date: Mar 2001
Location: Groton, CT, USA
Posts: 1,291
Thanks: 0
Thanked 0 Times in 0 Posts
chemistry_geek is on a distinguished road
Need help with shell scripts

I need help with creating a shell script for a project at work. I know this doesn't have anything to do with Macs, but I need a little direction to get this project going.

I just need to know when two text files "enterQ" (gets smaller over time) and "doneQ" (gets larger over time) haven't changed in 20 minutes.

Any help would be greatly appreciated! I just need to be pointed in the right direction to get this project started. I have a UNIX Shells book at work, but it is old. I'm working with Sun workstations running Solaris 8.
Reply With Quote
  #2  
Old February 20th, 2004, 12:00 AM
mr. k's Avatar
Registered User
 
Join Date: Oct 2002
Location: mpls. mn
Posts: 1,408
Thanks: 0
Thanked 0 Times in 0 Posts
mr. k is on a distinguished road
I can give you a few links, I think all of these are bash scripting which should be compatible with whatever flavor of nix your using.
http://www.tldp.org/LDP/abs/html/
http://goforit.unk.edu/unix/assess.htm
http://goforit.unk.edu/unix/unix14.htm
http://www.macinstruct.com/tutorials/unix/
http://www.matisse.net/OSX/TOC.html
Hope those help.
__________________
iMac G3 600Mhz, 256MB RAM, 40GB HD, 10.3.5
20GB iPod (Click Wheel) w/ Griffin iTrip // AIM:kjell05
Reply With Quote
  #3  
Old February 20th, 2004, 11:09 AM
WeeZer51402's Avatar
Right 00.1% of the Time
 
Join Date: Dec 2002
Location: Lost in my own unintelligible ramblings
Posts: 473
Thanks: 0
Thanked 0 Times in 0 Posts
WeeZer51402 is on a distinguished road
Are you familiar with C/C++, if so you may want to look into tcsh and csh scripting, the shell scripts or the tcsh and csh use similiar syntax to C. I think there is some tcsh stuff at the link below, you may find more support for bash scripting though.
http://www.shelldorado.com/links/
__________________
ON THE WAY:
15" PB 1.67|100|1024 --- 10.4
------------------------------------------
17" iMac G5 1.8|80|512|BT --- 10.3.9
FrankenMac G4 500|55|640 --- 10.3.9
PowerMac 9600 300|4|512 --- 1.2
eMachine 500is 500|4.3|196 --- OpenStep 4.2
Server 2.3|260|512 --- FedoraCore
Reply With Quote
  #4  
Old February 20th, 2004, 04:10 PM
Registered User
 
Join Date: Mar 2001
Location: Groton, CT, USA
Posts: 1,291
Thanks: 0
Thanked 0 Times in 0 Posts
chemistry_geek is on a distinguished road
Quote:
Originally Posted by WeeZer51402
Are you familiar with C/C++, if so you may want to look into tcsh and csh scripting, the shell scripts or the tcsh and csh use similiar syntax to C. I think there is some tcsh stuff at the link below, you may find more support for bash scripting though.
http://www.shelldorado.com/links/
No, I'm not familar with C/C++.

I remember asking if there was a shell script or sequence of commands that did the equivalent of "getinfo" in the Finder. I know that Panther has a "getinfo" command in the terminal now, but before that, it didn't exist. Someone replied with a series of commands that gave the file name, creation date, modification date, size, etc... but I can't find the thread. I've searched though the forums and can't find the thread. Perhaps it was lost during a site crash. Gosh, I even saved that hint. I'm at work now, and I know I have it saved somewhere. I think seeing a small script like that would help me. All I need to do then is rename a file, and compare size and modification date 20 minutes later IF the file is greater than a specified minimal size.

Anyone know how to do a "getinfo" using shell commands?
Reply With Quote
  #5  
Old February 20th, 2004, 04:47 PM
WeeZer51402's Avatar
Right 00.1% of the Time
 
Join Date: Dec 2002
Location: Lost in my own unintelligible ramblings
Posts: 473
Thanks: 0
Thanked 0 Times in 0 Posts
WeeZer51402 is on a distinguished road
just make sure you run chmod u=rwx on this file, i hope it does what you want it to, to use it just run it like any other unix command "getinfo /path/to/file". Good Luck!
Code:
#!/bin/bash
echo "Current Working Directory is $PWD"
ls -al | grep "$1"
__________________
ON THE WAY:
15" PB 1.67|100|1024 --- 10.4
------------------------------------------
17" iMac G5 1.8|80|512|BT --- 10.3.9
FrankenMac G4 500|55|640 --- 10.3.9
PowerMac 9600 300|4|512 --- 1.2
eMachine 500is 500|4.3|196 --- OpenStep 4.2
Server 2.3|260|512 --- FedoraCore
Reply With Quote
  #6  
Old February 21st, 2004, 04:22 PM
Registered User
 
Join Date: Mar 2001
Location: Groton, CT, USA
Posts: 1,291
Thanks: 0
Thanked 0 Times in 0 Posts
chemistry_geek is on a distinguished road
Quote:
Originally Posted by WeeZer51402
just make sure you run chmod u=rwx on this file, i hope it does what you want it to, to use it just run it like any other unix command "getinfo /path/to/file". Good Luck!
Code:
#!/bin/bash
echo "Current Working Directory is $PWD"
ls -al | grep "$1"

Thank you for the help. I'll have to try this when I get home.
Reply With Quote
  #7  
Old February 22nd, 2004, 06:52 PM
WeeZer51402's Avatar
Right 00.1% of the Time
 
Join Date: Dec 2002
Location: Lost in my own unintelligible ramblings
Posts: 473
Thanks: 0
Thanked 0 Times in 0 Posts
WeeZer51402 is on a distinguished road
Your welcome , I hope that script works for you, if not post back and ill see what else i can think of.
__________________
ON THE WAY:
15" PB 1.67|100|1024 --- 10.4
------------------------------------------
17" iMac G5 1.8|80|512|BT --- 10.3.9
FrankenMac G4 500|55|640 --- 10.3.9
PowerMac 9600 300|4|512 --- 1.2
eMachine 500is 500|4.3|196 --- OpenStep 4.2
Server 2.3|260|512 --- FedoraCore
Reply With Quote
  #8  
Old February 22nd, 2004, 07:45 PM
Registered User
 
Join Date: Mar 2001
Location: Groton, CT, USA
Posts: 1,291
Thanks: 0
Thanked 0 Times in 0 Posts
chemistry_geek is on a distinguished road
I tried the script, it doesn't do what I want it to do. I was digging around the Apple Developer CD that comes with Panther. In order for me to get the "GetFileInfo" shell script/executable, I have to install the full Developer tools. I only have 2GB left on my HD, and the install requires 1.5GB. Guess I'll have to go without for a while until I can clear off some more stuff. I found the man page for it by using "locate GetFileInfo" and the path for the man page comes up, but no path for the command.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 08:36 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.