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
Related
I am trying to get the results (CPU Temperature remote machine) from a .sh file using curl, Instead I receive the code from the .sh.
my current code
curl -s http://192.168.1.5/cgi-bin/temp.sh
instead of returning the temp it returns the .sh file code
I am running Apache2, and if I place the sh in a index.php file, I can grep the output, but that seems like a step too much.
Thanks for any advice.
Tried changing file to .cgi instead. Same results
I found changing my curl command to the following resolved the issue:
curl -s http://192.168.1.5/cgi-bin/temp.sh | sh
I just pipe my curl command to sh to return the result.
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.
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.
im trying to use that option of read command in my script but i get only the error message 'read: -d ilegal option' when i execute it. This is the code
#!bin/bash
read -d "." -p "Write here: " var
var>$1
Im trying to type the same code on terminal and its ok there.
I've checked the version's shell and is bash. Thanks for help
Run your script explicitly with bash script.sh not sh script.sh. Also make sure you have bash: bash --version.