Page 1 of 1

Why does mkdir not work?

Posted: Wed Jan 17, 2024 7:10 am
by madmax25
I'm inside a folder New folder and I'm trying to create folders 401 to 450, using this command

Code: Select all

mkdir ./{401..450}
which is inside of a file called create_folders.sh.

If I try to "Execute in terminal", using the context menu, I get an error message telling me:

Code: Select all

Executing child process failed
Child process "path/currently/opened" not executed
file or folder not found
...even that I'm already in that folder.

What's the fault here, please?

Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 7:43 am
by Charlie Brown
Then, does it work if you issue it directly in a terminal?

Also: Is the sh executable? ( chmod +x create_folders.sh )

Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 8:25 am
by Adrian
Anything else is that script? I tried the command and it works fine for me, I would change two things, I would not use spaces in "New Folder" I would use "New_Folder" or something like that and probably won't use ./ in the mkdir command, that's not necessary since it run that in current folder, I would use "mkdir {401..450}"

Please post the script...

Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 8:29 am
by Charlie Brown
Adrian wrote: Wed Jan 17, 2024 8:25 am... tried the command and it works fine for me ...
Same here. However it works here also in a folder with spaces: Charlie Brown :) (... either with and without ./ )

Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 12:58 pm
by madmax25
Sorry, of course, I mean New_folder with the underline.

It is actually not an entire script. It is just the command

Code: Select all

mkdir {401..450}
in a .sh file (nothing else inside), which is indeed executable already.

I tried both

Code: Select all

mkdir {401..450}
and

Code: Select all

mkdir ./{401..450}
but none of them worked.

But that command (both of them) did work perfectly, when executed directly from within a terminal.
So, I don't understand why it doesn't work if it is inside of a .sh file?

I checked the properties of that file and noticed, the owner is root.
That file is on a NTFS partition btw..
Could this be the reason?

Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 1:07 pm
by timkb4cq
It's because that syntax is only valid in bash/dash. You are in bash at the command line so it works. A shell script is not unless specified.
if you add the shebang line

Code: Select all

#!/bin/bash
to the first line of the script file it works.

Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 1:10 pm
by CharlesV
This worked perfectly for me on an ntfs drive.

You might try formatting your script as follows: (although mine worked fine with out this.)

Code: Select all

#!/bin/bash
 
mkdir ./{401..450}


Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 1:26 pm
by madmax25
After adding the shebang, it still failed to work, with same error message as in the opening post.

@ CharlesV
I copied your code exactly as it is, but still the same negative result.

Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 1:29 pm
by korilius
Post the script somewhere so we can look at it that way. It probably doesn't matter, but.. post which MX version you're running as well.

Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 1:34 pm
by madmax25
On my latest attempt I was using the code from CharlesV.

I'm still running MX 19.4 xfce 64 bit.

Actually, I planned to upgrade to the latest MX on both my PC and notebook right after the new year began, but then my notebook died and I'm currently waiting for the new one to be delivered (it is already ordered).

Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 1:53 pm
by CharlesV
I tested in mx19.4 and it worked for me there as well.

What does your context command look like?

Mine is custom action of:

Code: Select all

bash %f;


Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 2:19 pm
by madmax25
This is my context command of "Execute in terminal":

Code: Select all

xfce4-terminal -e %f --hold

Re: Why does mkdir not work?  [Solved]

Posted: Wed Jan 17, 2024 3:10 pm
by CharlesV
Try changing to this: (or create a second one to test it on )

command:

Code: Select all

bash %f;


Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 4:15 pm
by madmax25
Wow! Great! That one did work! Thank you!

Unfortunately, I don't remember where this wrong command came from, since this MX installation is already a few years old.

Re: Why does mkdir not work?

Posted: Wed Jan 17, 2024 4:19 pm
by CharlesV
Excellent! glad we found it.

Please mark as solved using the check mark on the post that resolved it.