How to stop process, exit shell [SOLVED]

interpretive language scripts


Moderator: Forum moderators

Post Reply
geo_c
Posts: 2501
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1799 times
Been thanked: 705 times

How to stop process, exit shell [SOLVED]

Post 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
Last edited by geo_c on Sat Oct 29, 2022 3:54 pm, edited 2 times in total.

geo_c
Old School Hipster, and Such

Burunduk
Posts: 244
Joined: Thu Jun 16, 2022 6:16 pm
Has thanked: 6 times
Been thanked: 122 times

Re: How to stop process, exit shell

Post 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.

geo_c
Posts: 2501
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1799 times
Been thanked: 705 times

Re: How to stop process, exit shell

Post 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.

geo_c
Old School Hipster, and Such

Post Reply

Return to “Scripts”