Running .sh file says "no such file or directory" even though it exists


#1

.yml Code:

platform: linux
image_resource:
type: docker-image
source:
repository: busybox
tag: latest
inputs:

  • name: Testing
    run:
    path: ./Testing/test.sh

test.sh code:

#!/usr/bin/bash
cat Hello.txt

Error (Image):


#2

It looks like you don’t have tar in your environment. fly is looking for it in /usr/bin/ but can’t find it.


#3

On a related note, the requirement to have tar installed on windows should be going away in 4.0-

https://concourse-ci.org/download.html#v400


#4

I’m not using linux, i’m running concourse on windows 10 using Docker


#5

What matters for fly execute is the system you’re running fly from, not the OS the actual Concourse is running from. The error you’re seeing is because tar is not found in your machines’s PATH.


#6

Now, i have completely modified the code & removed all the errors. This new code is supposed to run a Simple Java Program.
java.yml code (image):
image

java.sh code (image):
image

Error(image):
image

I have hijacked the container and it shows my git-repo (resource name) & all the files present in the repository.

Conatiner Details (Image):
image


#7

When you hijack you are choosing to enter the get container not the task choose option 2 instead then investigate that container.


#8

Here is the Details of Container 2

image


#9

Its probably something to do with file paths or file permissions. I’m not familiar with javac but try running ./git-repo/java.sh from the directory the hijack first drops you into (/tmp/build/fbb96911 in the screenshot above).


#10

@crsimmons i updated it to ./git-repo/java.sh still it’s taking into /tmp/build/fbb96911/


#11

I think you misunderstood. Run the command ./git-repo/java.sh from the directory /tmp/build/fbb96911/ and see what happens.

Your pipeline looks like its set up correctly so I think this is a problem with your script rather than a Concourse issue.


#12

From the container i have ran ./git-repo/java.sh


#13

All I can suggest is trying to get it to work in the container then make the necessary changes to your script/pipeline to make it pass in general.

Since it doesn’t work in the container this is not a Concourse problem.


#14

from the container if i do cd git-repo & ./java.sh it works fine.


#15

So in your script you need to make sure the working directory is set to the directory of the script before running javac.

Something like this.


#16

cd “$(dirname “$0”)” if i use this command it’s going directly into usr/bin directory.
i’m using Git Bash on Windows.
Can u please write the command to include before javac line in script (java.sh)


#17

If you modify the java.sh script in the hijacked container then run ./git-repo/java.sh from /tmp/build/fbb96911/ I would expect cd “$(dirname “$0”)” to work. If it doesn’t you’re going to have to find something that does. There isn’t really anything else I can suggest.


#18

Its not working :triumph: !!


#19

I just tried it myself. From the hijacked container I changed the script to be:

$ cat git-repo/java.sh
#!/bin/bash
cd "$(dirname "$0")"
javac samp.java
java samp

The I ran:

$ ./git-repo/java.sh
Hello World

Seems to be working fine.


#20

Ya thanks, now its working very well.
You are the only one who spotted the mistake.