Score:0

Not able to run a program with a .sh script using Ubuntu WSL

fr flag

I am new to Ubuntu. I installed Ubuntu on Windows 10 to run a program with Linux using ubuntu.

When I double-click on the Ubuntu app I get a shell (believe it is a WSL shell) with my username@Desktop-IULTFHD-. Inside this shell, I get some info on root etc. for couple of lines and my username@Desktop-IULTFHD: $

I type cd to change the directory to the location of the software. Then I run the .sh script. However, it is either saying too many arguments or this command not found.

Can someone help to check:

  1. Have I downloaded correct version of Ubuntu app.
  2. If so, how to cd to get the path to direct that particular file and open the script.
  3. DO I have the correct WSL
hr flag
Please [edit] your question to include the exact command(s) you typed and the complete error messages.
Nmath avatar
ng flag
Also tell us what script you are trying to run and where you obtained it. Ubuntu over WSL cannot run all software. It can be very different from Ubuntu installed on bare metal. In particular, Ubuntu over WSL does not officially support GUI applications or desktop environments and does not have direct access to hardware. So if you are trying to run something that needs to make changes to hardware or a script that requires a window, it's probably not going to run on WSL, at least not with some off-spec tweaking
hr flag
The most likely issue is that you are trying to `cd` to a path that contains whitespace - see for example [I need to cd into directory with spaces `-bash: cd: too many arguments`](https://askubuntu.com/questions/1205757/i-need-to-cd-into-directory-with-spaces-bash-cd-too-many-arguments)
Score:1
bo flag

You cd to the directory that contains the file, not the file itself. Alternatively, you can skip the cd command and just run the file by executing the full path of the file including the filename.

Example execution of a file named script.sh in your ~/Downloads directory (assuming your user name is surendar):

/home/surendar/Downloads/script.sh

or to cd:

cd /home/surendar/Downloads

and then to run the example file named "script.sh"

./script.sh

You must prefix the script or file name with ./ if the file is in your current directory or it will not run.

mchid avatar
bo flag
Also, be careful, *nix based systems are case sensitive unlike Windows.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.