The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 12:06 AM
IBM Demonstrates a UNIX Virtualization Exclusive, Moves Workloads ... - CNNMoney.com iBot UNIX and Linux RSS News 0 08-07-2007 09:10 PM
IBM Demonstrates a UNIX Virtualization Exclusive, Moves Workloads ... - MySolutionInf iBot UNIX and Linux RSS News 0 08-07-2007 07:30 AM
IBM Demonstrates a UNIX Virtualization Exclusive, Moves Workloads ... - CNNMoney.com iBot UNIX and Linux RSS News 0 08-06-2007 03:10 PM
Apple Moves Slowly, Surely Into Big Business - The Mac Observer iBot UNIX and Linux RSS News 0 08-03-2007 10:50 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-01-2006
Registered User
 

Join Date: Feb 2006
Location: The OS.
Posts: 1
Script that moves itself

Hello all, I'm new here, so if this is in the wrong place please feel free to move it.

As a challenge to myself, I've decided I want to make a "alive" script. Well not really, but almost.

I want to make a script that will rove around my hard drive in the background (actually "moving" itself), and record the files it sees. Sorta like a mini mars rover... in my computer.

I'm on Mac OS 10.4.4, so I'm on UNIX/Darwin underneath, and my general question is:

Can I make a script that can actually move itself? I can see the obvious difficulties; "Item in use, permission denied!" etc...

I'd like to be able to do it without using another script, but somehow I think I already know the answer, but please tell me I'm wrong.
Reply With Quote
Forum Sponsor
  #2  
Old 02-02-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
Have you considered the "cd" command?

If you want to use your model, then maybe something like this...
Code:
..............
cat $0 > /new/path/myfile.sh
chmod +x /new/path/myfile.sh
/new/path/myfile.sh
exit
Reply With Quote
  #3  
Old 02-02-2006
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,212
Quote:
Code:
..............
cat $0 > /new/path/myfile.sh
chmod +x /new/path/myfile.sh
/new/path/myfile.sh
exit
Never finishes ...

Perhaps something like that :
Code:
..............
target_file=/new/path/myfile.sh
if [ $0 != $target_file ]
then
   cp $0 $target_file
   chmod +x $target_file
   $target_file
fi
exit
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0