![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#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. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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 |
|
#3
|
||||
|
||||
|
Quote:
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 |
||||
| Google The UNIX and Linux Forums |