No such file or directory when changing directory: Running shell script in ubuntu in windows 10

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite












I have been having issues changing directories using a shell script in windows 10.



In notepad I created a file, test.sh, which has the following script:



#!/bin/bash
cd '/mnt/p/WMScriptTest/'


I then mounted the Ubuntu terminal to the location of the test.sh file by typing in cd /mnt/p/ which works. Next, I typed in ./test.sh and keep getting the following error message:



: No such file or directory/p/WMScriptTest/


I am new to using ubuntu and any help/suggestions are greatly appreciated.
Thank you







share|improve this question





















  • Please edit and add the output of ls -l /mnt/p. In a script one normally doesn’t use cd, but rather absolute paths. You can store paths in variables if that makes it easier, e.g. mypath=/mnt/p/WMScriptTest and then mkdir "$mypath/mydir" and cp "$mypath/file1" "$mypath/mydir".
    – dessert
    Jun 4 at 18:08










  • I just seem to be unable to change directories from code in my shell script. One of the folders listed from ls -l /mnt/p/ is WMScriptTest that I am trying to change directories to. If I change directories within the terminal itself it works though.
    – Justin S.
    Jun 4 at 18:44











  • Is the error message really (literally) : No such file or directory/p/WMScriptTest/? That looks mangled somehow…
    – dessert
    Jun 4 at 18:46










  • Yes, that is the exact message that I get
    – Justin S.
    Jun 4 at 18:47






  • 2




    Maybe a problem with line endings? askubuntu.com/q/803162/507051
    – dessert
    Jun 4 at 18:48














up vote
0
down vote

favorite












I have been having issues changing directories using a shell script in windows 10.



In notepad I created a file, test.sh, which has the following script:



#!/bin/bash
cd '/mnt/p/WMScriptTest/'


I then mounted the Ubuntu terminal to the location of the test.sh file by typing in cd /mnt/p/ which works. Next, I typed in ./test.sh and keep getting the following error message:



: No such file or directory/p/WMScriptTest/


I am new to using ubuntu and any help/suggestions are greatly appreciated.
Thank you







share|improve this question





















  • Please edit and add the output of ls -l /mnt/p. In a script one normally doesn’t use cd, but rather absolute paths. You can store paths in variables if that makes it easier, e.g. mypath=/mnt/p/WMScriptTest and then mkdir "$mypath/mydir" and cp "$mypath/file1" "$mypath/mydir".
    – dessert
    Jun 4 at 18:08










  • I just seem to be unable to change directories from code in my shell script. One of the folders listed from ls -l /mnt/p/ is WMScriptTest that I am trying to change directories to. If I change directories within the terminal itself it works though.
    – Justin S.
    Jun 4 at 18:44











  • Is the error message really (literally) : No such file or directory/p/WMScriptTest/? That looks mangled somehow…
    – dessert
    Jun 4 at 18:46










  • Yes, that is the exact message that I get
    – Justin S.
    Jun 4 at 18:47






  • 2




    Maybe a problem with line endings? askubuntu.com/q/803162/507051
    – dessert
    Jun 4 at 18:48












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have been having issues changing directories using a shell script in windows 10.



In notepad I created a file, test.sh, which has the following script:



#!/bin/bash
cd '/mnt/p/WMScriptTest/'


I then mounted the Ubuntu terminal to the location of the test.sh file by typing in cd /mnt/p/ which works. Next, I typed in ./test.sh and keep getting the following error message:



: No such file or directory/p/WMScriptTest/


I am new to using ubuntu and any help/suggestions are greatly appreciated.
Thank you







share|improve this question













I have been having issues changing directories using a shell script in windows 10.



In notepad I created a file, test.sh, which has the following script:



#!/bin/bash
cd '/mnt/p/WMScriptTest/'


I then mounted the Ubuntu terminal to the location of the test.sh file by typing in cd /mnt/p/ which works. Next, I typed in ./test.sh and keep getting the following error message:



: No such file or directory/p/WMScriptTest/


I am new to using ubuntu and any help/suggestions are greatly appreciated.
Thank you









share|improve this question












share|improve this question




share|improve this question








edited Jun 4 at 18:01









dessert

19.4k55494




19.4k55494









asked Jun 4 at 17:58









Justin S.

1




1











  • Please edit and add the output of ls -l /mnt/p. In a script one normally doesn’t use cd, but rather absolute paths. You can store paths in variables if that makes it easier, e.g. mypath=/mnt/p/WMScriptTest and then mkdir "$mypath/mydir" and cp "$mypath/file1" "$mypath/mydir".
    – dessert
    Jun 4 at 18:08










  • I just seem to be unable to change directories from code in my shell script. One of the folders listed from ls -l /mnt/p/ is WMScriptTest that I am trying to change directories to. If I change directories within the terminal itself it works though.
    – Justin S.
    Jun 4 at 18:44











  • Is the error message really (literally) : No such file or directory/p/WMScriptTest/? That looks mangled somehow…
    – dessert
    Jun 4 at 18:46










  • Yes, that is the exact message that I get
    – Justin S.
    Jun 4 at 18:47






  • 2




    Maybe a problem with line endings? askubuntu.com/q/803162/507051
    – dessert
    Jun 4 at 18:48
















  • Please edit and add the output of ls -l /mnt/p. In a script one normally doesn’t use cd, but rather absolute paths. You can store paths in variables if that makes it easier, e.g. mypath=/mnt/p/WMScriptTest and then mkdir "$mypath/mydir" and cp "$mypath/file1" "$mypath/mydir".
    – dessert
    Jun 4 at 18:08










  • I just seem to be unable to change directories from code in my shell script. One of the folders listed from ls -l /mnt/p/ is WMScriptTest that I am trying to change directories to. If I change directories within the terminal itself it works though.
    – Justin S.
    Jun 4 at 18:44











  • Is the error message really (literally) : No such file or directory/p/WMScriptTest/? That looks mangled somehow…
    – dessert
    Jun 4 at 18:46










  • Yes, that is the exact message that I get
    – Justin S.
    Jun 4 at 18:47






  • 2




    Maybe a problem with line endings? askubuntu.com/q/803162/507051
    – dessert
    Jun 4 at 18:48















Please edit and add the output of ls -l /mnt/p. In a script one normally doesn’t use cd, but rather absolute paths. You can store paths in variables if that makes it easier, e.g. mypath=/mnt/p/WMScriptTest and then mkdir "$mypath/mydir" and cp "$mypath/file1" "$mypath/mydir".
– dessert
Jun 4 at 18:08




Please edit and add the output of ls -l /mnt/p. In a script one normally doesn’t use cd, but rather absolute paths. You can store paths in variables if that makes it easier, e.g. mypath=/mnt/p/WMScriptTest and then mkdir "$mypath/mydir" and cp "$mypath/file1" "$mypath/mydir".
– dessert
Jun 4 at 18:08












I just seem to be unable to change directories from code in my shell script. One of the folders listed from ls -l /mnt/p/ is WMScriptTest that I am trying to change directories to. If I change directories within the terminal itself it works though.
– Justin S.
Jun 4 at 18:44





I just seem to be unable to change directories from code in my shell script. One of the folders listed from ls -l /mnt/p/ is WMScriptTest that I am trying to change directories to. If I change directories within the terminal itself it works though.
– Justin S.
Jun 4 at 18:44













Is the error message really (literally) : No such file or directory/p/WMScriptTest/? That looks mangled somehow…
– dessert
Jun 4 at 18:46




Is the error message really (literally) : No such file or directory/p/WMScriptTest/? That looks mangled somehow…
– dessert
Jun 4 at 18:46












Yes, that is the exact message that I get
– Justin S.
Jun 4 at 18:47




Yes, that is the exact message that I get
– Justin S.
Jun 4 at 18:47




2




2




Maybe a problem with line endings? askubuntu.com/q/803162/507051
– dessert
Jun 4 at 18:48




Maybe a problem with line endings? askubuntu.com/q/803162/507051
– dessert
Jun 4 at 18:48















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1043569%2fno-such-file-or-directory-when-changing-directory-running-shell-script-in-ubunt%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1043569%2fno-such-file-or-directory-when-changing-directory-running-shell-script-in-ubunt%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

pylint3 and pip3 broken

Missing snmpget and snmpwalk

How to enroll fingerprints to Ubuntu 17.10 with VFS491