Script that moves itself


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script that moves itself
# 1  
Old 02-02-2006
Script that moves itself

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

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. Smilie
# 2  
Old 02-02-2006
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  
Old 02-02-2006
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

Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to check one command and if it fails moves to other command

Input is list of Server's, script is basically to remove old_rootvg, So it should check first command "alt_rootvg_op -X old_rootvg" if it passes move to next server and starts check and if it fails moves to other command "exportvg old_rootvg" for only that particular server. I came up with below,... (6 Replies)
Discussion started by: aix_admin_007
6 Replies

2. Shell Programming and Scripting

How to wite shell script to moves files?

Greetings to all, i am new to shell scripting. i need to wite a script that moves files after renaming them to .txt . The exact scenario is this. i have a directory /stsarie/btms/v5.0/report/wps where files will be imported from Host system periodically. Along with a file say named... (2 Replies)
Discussion started by: latrom77
2 Replies

3. UNIX for Dummies Questions & Answers

Traffic moves to another eth

hi guys I have a server which has 2 nics eth0 and eth1 eth0 is used for our email traffic server. everything working fine some time later a eth1 was added for backup purposes so this new nic sends data to another vlan for backup purposes all of a sudden our mail server starts to fail... (3 Replies)
Discussion started by: karlochacon
3 Replies

4. Windows & DOS: Issues & Discussions

Script that, if file exists in Samba share, moves file to Unix server

I'm looking to do pretty much what the title says. I want a script that runs, it can run on Unix or Windows, doesn't matter, and searches a Samba shares for a .txt file. If the file exists, the script will move (or possibly copy) the file from the Samba share into a directory on our Unix... (3 Replies)
Discussion started by: twcostello
3 Replies

5. Shell Programming and Scripting

moves checkout files to local system

I am using my script which generally checkout the repository.Is there any coomand which can help me to checkout the repository not on that svn server while it moves it to your local system at the desired location. (0 Replies)
Discussion started by: rohit22hamirpur
0 Replies

6. Shell Programming and Scripting

moves files remotely using ftp

Hi All, How can i move files from one directory to another in remote server using ftp? Thanks in Advance, (4 Replies)
Discussion started by: HemaV
4 Replies
Login or Register to Ask a Question