Hello everyone.
Let's say i have 2 scripts called "fill_cup.sh" and "empty_cup.sh" and i create a 3rd script "cup.sh". How can i run/execute the scripts "fill_cup.sh" and "empty_cup.sh" in the script "cup.sh". I tried with sh fill_cup.sh and ./fill_cup.sh but it doesn't work.

for example

Script cup.sh

#!/bin/sh

echo enter a number

read rep

if test $rep eq 1
then
#execute the script "fill_cup.sh"
./fill_cup.sh #error: No such file or directory
done

if test $rep -eq 2
then
#execute script "empty_cup.sh"
./empty_cup.sh #error: No such file or directory
done

It gives me "No such file or directory" error
I gave the scripts all the permissions to read write and execute. I also made sure i'm present in the directory where the scripts are located and the run cup.sh but it still gives me the same error when it arrives to ./fill_cup.sh

Seemingly your pwd is not what you think it is.

try this to seewhat is happening:

/bin/sh -x cup.sh
it will show you each line and result as it executes.

Seemingly your pwd is not what you think it is.

I thought about that but 200% sure that i'm in the right directory. pwd even shows that i'm in the right directory

edit: funnily it's working now. seems my pwd wasn't what i thought it was but i'm 100% sure that i'm was the right directory. By the way i'm using cygwin on windows and writing the code on wordpad. Don't know if that had any influence on the error.

Thanks all

Just a suggestion I used to work with cygwin I just switched to Putty and it works better! give it a try!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.