When i try to run bash xfce4.sh, it gives me the error:
xfce4.sh: line 1: syntax error near unexpected token <'
xfce4.sh: line 1: <html><head><title>Loading...</title></head><body><script type='text/javascript'>window.location.replace('https://kali.sh/xfce4.sh?ch=1&js=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJKb2tlbiIsImV4cCI6MTY2NjkxMzIzMCwiaWF0IjoxNjY2OTA2MDMwLCJpc3MiOiJKb2tlbiIsImpzIjoxLCJqdGkiOiIyc2gwa2QwZW4xdWdicTlvaGMwdDRwb2EiLCJuYmYiOjE2NjY5MDYwMzAsInRzIjoxNjY2OTA2MDMwNzgyMDIxfQ.tN_1ZFHTKGGPtECn_V_PNJhsE8II0fcxWjYnZhB9evc&sid=1de40110-563e-11ed-ba81-f9449723c437');</script></body></html>'
I have tried to install dos2unix and converted xfce4.sh to Unix format, but still gave the same problem.
You're trying to run an HTML file as a bash script.
After you download the correct file, you also need to make it executable:
chmod +x xfce4.sh
Then execute it; you can also execute a script with:
./xfce4.sh
Assuming your current directory is the same as the script's directory.
Related
I'm a definite Python newbie, so the answer here may be obvious. But I'm trying to change a simple .py file's permissions so it can be run directly from the Terminal window (I'm running Python3 from a Macbook). I've entered the shebang line #! /usr/bin/env python3 at the top of my script, but according to the tutorial I'm following, I next need to run the following command:
chmod +x pythonScript.py
But every time I try running this either from Terminal or the Python shell, I get the following syntax error:
>>> chmod +x pythonScript.py
File "<stdin>", line 1
chmod +x pythonScript.py
^
SyntaxError: invalid syntax
Any ideas on what I'm missing? How do I change the file permission so I can execute a file directly from the Terminal window?
You probably already figured it out but just in case there are others with a similar question.
Your .py file should be saved to your home folder. Say my file is name.py.
When you open the terminal (with current working directory of your home folder) type the command chmod +x name.py.
Now you will be able to run the file in the terminal by typing ./name.py
only use pythonScript.py if that is the name of your .py file
You should run chmod +x filename and ./filename not in python env(>>>). But in directory
I am not familiar with Linux, just basic commands, I want to use the command below on Ubuntu but I get syntax error.
Command:
curl --progress-bar "http://community.nanocloud.com/nanocloud.sh" | sh
Error:
sh: 2: Syntax error: newline unexpected
You should save the content of the downloaded file first (e.g. using wget instead of curl) and then run sh on the saved file.
wget "http://community.nanocloud.com/nanocloud.sh";
sh nanocloud.sh
I am very new to linux and shell scriprting.
I am trying to run a shellscript from secure shell (ssh) on linux using following commands:
chmod +x path/to/mynewshell.sh
sh path/to/mynewshell.sh
I get this error:
path/to/mynewshell.sh: path/to/mynewshell.sh: cannot execute binary file.
Tried using this command:
bash path/to/mynewshell.sh
I get the same error.
Tried with this command: su - myusername sh path/to/mynewshell.sh
It is asking for my password and giving me this error: no such file or directory.
1.The result of cat -v path/to/mynewshell.sh is:
^#^#^#^#^#^#^#^#Rscript "$dir"/diver_script.R
done
2.When tried 'less path/to/mynewshell.sh' i got this on my terminal:
#!/bin/bash/Rscript^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#
^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#^#
for dir in /path/to/* ; do
^#^#^#^#^#^#^#^#Rscript "$dir"/myRscript.R
done
3.When i ran file path/to/mynewshell.sh : i got this "Bourne-Again shell script text executable"
Please give any advice on how I can try executing the shellscript.
chmod -x removes execution permission from a file. Do this:
chmod +x path/to/mynewshell.sh
And run it with
/path/to/mynewshell.sh
As the error report says, you script is not actually a script, it's a binary file.
I was getting the same error running my shell script through a bash interpreter in PowerShell. I ran dos2unix myscript.sh on the shell script, and now it runs ok.
From a proposed duplicate:
run_me.sh.xz: run_me.sh.xz: cannot execute binary file
This is because the file is compressed, as indicated by the .xz extension. You need to remove the compression before the file can be used.
xz -d ./run_me.sh.xz
chmod +x ./run_me.sh # probably not necessary if you already did that before
./run_me.sh
Other compression schemes like gzip (.gz extension), bzip2 (.bz2 extension) etc behave similarly; you just have to know the name of the command to uncompress it, which is of course usually easy to google.
To anyone else having the problem i had.
i was trying to run a 16 bit unicode text file converted to a shell script, this doesn't work as all 16 bit unicode text files have a 0xFFFE marker at the start making mac os not like the file and this gives the “cannot execute binary file” error.
open the text file click on "Format" at the top, go down to "Make Plain Text" click it.
open your terminal type chmod 777 /path/to/file.sh
put in terminal: /path/to/file.sh to run it
That script is simply not a shell script.
A shell script is usually readable and contains shell code.
The output your cat command shows looks indeed like it's a binary of some sort.
As some note, it might be because of a file conversion issue when copying but it looks more like an actual binary to me.
You can check what it is identified as with the file command so:
file path/to/mynewshell.sh
Just start with a clean script and rewrite the code, it looks like you just want to run some R scripts in a directory?
Make sure the R scripts point to the right R script executioner.
In my case I had a bash script that would not execute. The file was originally generated from a find ... -print0 command. Leaving a \0 character the script, removing that character solved my problem.
I get the following error (error.message) when I run the following shell script (myscript.sh).
myscript.sh
#!/bin/bash
cd /path/to/ && node app.js
error.message
/path/to/myscript.sh: line 1: #!/bin/bash: No such file or directory
/path/to/myscript.sh: line 2: node: command not found
I have already run the following command line instructions.
command-line
chmod u+x /path/to/myscript.sh
chmod u+x /path/to/app.js
Also, I know I have node installed because when I run:
node -v
I get back:
v5.5.1
I execute myscript.sh via the following AppleScript:
MyApp.applescript
do shell script "bash /path/to/myscript.sh"
Also: which bash returns /bin/bash
What could be causing this error and how can I fix it?
I fixed the first error:
/path/to/myscript.sh: line 1: #!/bin/bash: No such file or directory
By copying a working .sh file I had on my machine and copy/pasting the code from the old file to the new file.
I'm guessing somehow there was a filetype issue or discrepancy despite the fact that I used a .sh extension in the file name.
In the future, I will double check the file type in my Finder utility (Max OS X v10.10.1).
However, I am still seeing the second error:
/path/to/myscript.sh: line 2: node: command not found
Credit goes to #HeadCode and #mh-cbon for helping me figure this out with their comments.
I solved the second problem by running:
myshell.sh
#!/bin/bash
path/to/node path/to/app.js
where path/to/node was found by running
command-line
which node
and path/to/app.js is the actual file tree path to app.js. (In other words, different from path/to/node.)
I'm just trying to run a simple bash script and it's just not working. The entirety of the script is this:
#!/bin/bash
/home/pi/akr2.exe
Just those two lines but when I try to run it:
sh: 1: Syntax error: "(" unexpected
sh: 1: Syntax error: "(" unexpected
There are no parentheses. How is this possible?
Note: I get the same error message whether I run the script with ./script.sh or bash script.sh
I suspect you've compiled akr2.exe on Windows, downloaded it to a Raspberry Pi and try to run it.
Linux on ARM definitely cannot run a binary compiled for Windows on x86.
When Linux tryies to run it, does not find nor the ELF magic numbers for Linux binaries, nor a shebang for a script, at the beginning, so it attempts to run it with /bin/sh. But it's not a shell script, just a binary blob, so sh gives you a syntax error and exits.