Self deleting script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Self deleting script
# 8  
Old 10-31-2005
Thanks for the info re ksh ... always nice to learn new things :-)

My point was there is a difference between calling an executable shell script directly (./myscript.sh) and relying on the hash bang line to determine what shell to run it on (the current shell of course if no hash bang line is present) and calling it using a specific shell (ksh myscript.sh).

Under ksh vino's example works fine (using ./myscript.sh). Unless of course you call it using 'ksh myscript.sh' (and circumventing the hash bang line). Which was why I was trying to determine how it was called.
# 9  
Old 10-31-2005
I think this is the mechanism to provide command level atomicity.
If you change the script in between it just work as per
new set of commands .
# 10  
Old 11-01-2005
Quote:
Originally Posted by akrathi
I think this is the mechanism to provide command level atomicity.
If you change the script in between it just work as per
new set of commands .
Just out of curiosity.

What changes ? What will the final script look like ?
# 11  
Old 11-01-2005
I mean if you don't delete the the file . For example
if the shell script is like this

#!/bin/ksh

echo "Hello"
sleep 100
echo "World"

You run the command the script like say test.ksh

Then from other window change the script to look like this
during the program execution .

#!/bin/ksh

echo "Hello"
sleep 100
echo "World"
echo "Testing "

The command executed in first session will display will echo the text testing as well

What I meant here is this ... Statement level atomicity like in database is also maintained in the command level at os .
I probably read something about this during my school days ... may be the book was authored by stephen prata

Thanks
Ashok
# 12  
Old 11-01-2005
There is no "statement level atomicity". You cannot modify a running script and have any assurance that anything you expect might happen. ksh reads in buffers at a time until it has enough to run. When it needs more, it will read another buffer. It often has unprocessed input sitting in a buffer. It almost always splits a statement as it reads a buffer. It has a file pointer into the script. Like any other file pointer, it is a character position, not a line number.
# 13  
Old 11-02-2005
That was a highly informational series of posts-thanks every one. I didnt execute the script as "ksh remove.sh" but I had executed it as ". remove.sh" (which didnt work out). But executing it as "./remove.sh" works fine.
# 14  
Old 11-02-2005
Code:
. remove.sh

and
Code:
ksh remove.sh

are very similiar in the sense that they are passed as a parameter.

To

. - the current shell
ksh - a new ksh subshell.

vino
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script for deleting Files

Hello, I am new to shell scripting..i need your help. i have the delete the log files which are present in the specific path .i have the rules as below. 1)In Path1 i need to delete all the files which are present 2)in Path2 i need to keep 1 month of data and delete the rest of the data... (5 Replies)
Discussion started by: rajesh25
5 Replies

2. Shell Programming and Scripting

Help with Deleting Folders Script

Hi all new to the forums. Very beginner at shell scripting. What I'm trying to do is this: Is the directory empty prior to removal of it? If not, inform the user that the directory is not empty and if the user wants to remove it remove or move the files in it first. But I'm stuck.. It checks... (3 Replies)
Discussion started by: rduckett1456
3 Replies

3. Shell Programming and Scripting

Deleting Specific Characters in Script

What's one single UNIX pipeline that would delete all of the vowels from one file (global)? I know I would need to use the sed command. But I'm stuck after that. i know how to replace characters with other characters I just don't know how to fully get rid of it. (4 Replies)
Discussion started by: sarahahah
4 Replies

4. UNIX for Dummies Questions & Answers

Deleting a pattern in UNIX without deleting the entire line

Hi I have a file: r58778.3|SOURCES={KEY=f665931a...,fw,221-705}|ERRORS={16_1:T,30_1:T,56_1:C,57_1:T,59_1:A,101_1:A,115:-,158_1:C,186_1:A,204:-,271_1:T,305:-,350_1:C,368_1:G,442_1:C,472_1:G,477_1:A}|SOURCE_1="Contig_1092402550638"(f665931a359e36cea0976db191ff60ff09cc816e) I want to retain... (15 Replies)
Discussion started by: Alyaa
15 Replies

5. Shell Programming and Scripting

Script problem with deleting data

The 10.Delete data doesnt work at all, plesase anyone could help on that. When I choose options 10 to delete a record it only copy the selected data on the other file dbs1 but doesnt delete it from the database where other records are. #! /bin/bash i="y" echo "Enter name of database " read db... (6 Replies)
Discussion started by: Lina_14
6 Replies

6. Shell Programming and Scripting

Script for Deleting files

Hi All, I need a script which compares the sysdate and the file date(Last updated time stamp) and if the time difference is greater than 10 mins i need to delete that file. Can anyone help me pls?????? Ashok. (5 Replies)
Discussion started by: Ashok_oct22
5 Replies

7. Shell Programming and Scripting

Deleting table cells in a script

I'd like to use sed or awk to do this but I'm weak on both along with RE. Looking for a way with sed or awk to count for the 7th table data within a table row and if the condition is met to delete "<td>and everything in between </td>". Since the table header start on a specific line each time, that... (15 Replies)
Discussion started by: phpfreak
15 Replies

8. Shell Programming and Scripting

Script for deleting 30 days older

Hi, I need a script to delete files that are 30 days older and also the file name should contain aa or ab or ac as substring... Regards, Dolly.... (3 Replies)
Discussion started by: moon_friend
3 Replies
Login or Register to Ask a Question