Page 1 of 1

How to stop process, exit shell [SOLVED]

Posted: Sat Oct 29, 2022 2:16 pm
by geo_c

I run a lot of rsync scripts to keep my data in tact across storage media.

This question is not about that script, but about a script I use to drop a date-stamp file on the drive after I sync it.

It works fine, but I noticed when running it from Midnight Commander that the sub shell stays active. I tried adding "done" at the end of the script, but that doesn't change it.

How can I get it to exit the shell?

Code: Select all

#!/bin/bash

MYDIR=$(cd `dirname $0` && pwd)
cd $MYDIR

DATE=$(date +"%m%d.%H%M")
cat > $MYDIR/ALL-$DATE.log

done

Re: How to stop process, exit shell

Posted: Sat Oct 29, 2022 3:30 pm
by Burunduk
geo_c wrote: Sat Oct 29, 2022 2:16 pm

Code: Select all

#!/bin/bash

MYDIR=$(cd `dirname $0` && pwd)
cd $MYDIR

DATE=$(date +"%m%d.%H%M")
cat > $MYDIR/ALL-$DATE.log

done

Your cat waits for input. You've provided no arguments to it making it read from the stdin.

If all you need is a flag (an empty file), try:

Code: Select all

#!/bin/bash
touch ALL-$(date +"%m%d.%H%M").log

done is a part of a for/while/until loop: while ... ; do ... ; done It can't be used alone.


Re: How to stop process, exit shell

Posted: Sat Oct 29, 2022 3:56 pm
by geo_c
Burunduk wrote: Sat Oct 29, 2022 3:30 pm

Your cat waits for input. You've provided no arguments to it making it read from the stdin.

done is a part of a for/while/until loop: while ... ; do ... ; done It can't be used alone.

Of course! That's why they call me Captain Oblivous.