New to MINGW64 - command not found? - windows

I've been using MINGW64 for about 4 hours. So go easy on me. I'm having a problem where commands work when typed directly into the MINGW64 console, but fail when run from a simple .sh script.
Administrator#EC2AMAZ-I2CVOT2 MINGW64 /c/BuildAgent
$ drewtemp="hihi"
Administrator#EC2AMAZ-I2CVOT2 MINGW64 /c/BuildAgent
$ echo "${drewtemp}"
hihi
Administrator#EC2AMAZ-I2CVOT2 MINGW64 /c/BuildAgent
$ cat test.sh
#!/usr/bin/sh
unity="hi"
echo "${unity}"
Administrator#EC2AMAZ-I2CVOT2 MINGW64 /c/BuildAgent
$ ./test.sh
./test.sh: line 2: unity=hi: command not found
Can anyone tell me why this simple sh script results in "command not found"?
Thanks!

Related

bash shell script not executing in mac

I have a simple bash script test.sh
#!/bin/sh
# This is a comment
echo "Hi"
It does not execute anything when I try to run ./test.sh
$ ./test.sh
$
It comes with empty output. The mac terminal is executing echo commands but not shell script. I am not sure what I am missing. Please suggest.
to execute command file , type sh test.sh

running multiple command from bash script with out loosing control

I want to run these two command in a loop:
for i in cat input:
do
winpty Kubectl exec -it $i -n image -c podname -- sh
2nd command
done
When I am running the .sh file, the first command works fine and after than nothing is happening.Can anybody help on this?I am running through gitbash from windows machine
I'm a bash rookie, but maybe it's because of the lack of a defined -d directory for unzipped files?

bash: syntax error near unexpected token `newline' for "&! "

I have the following script.sh running in zsh. But since I am running the script as sudo user used shell differs between each other.
#!/bin/bash
echo $SHELL
nohup geth --syncmode fast --cache=1024 > geth_server.out 2>&1 &!
Output in macOS:
$ chmod +x script.sh
$ sudo ./script.sh
/bin/sh
syntax error near unexpected token `newline'
which generated following error on macOS but works fine in linux: syntax error near unexpected token newline'`
Output in linux:
$ chmod +x script.sh
$ sudo ./script.sh
/bin/bash
# works fine
The error seems like generated due to ! at the end of the line. Is there anyway to fix this, what may be the reason for this? Exact same script works fine in linux environment

How do I execute a remote script as a build phase in xcode?

I have a remote script which I can execute from command line without an issue:
bash <(curl -sSL 'goo.gl/p1GPQw') 29165BE4-EA61-8228-9F33-A9B9DAD481A0 ./Info.plist
Problem comes when I try to use it in as a build phase of my iOS app (to update a build number).
The error log:
/Users/pr.......: line 2: syntax error near unexpected token `('
/Users/pr.......: line 2: `bash <(curl -sSL 'goo.gl/p1GPQw') 7CD17FC7-E724-7240-34ED-927122733119 ./Info.plist'
So the question is, are there any limitations in what you can through xcode execute or is it some error in syntax?
Update:
If I change the /bin/sh to /bin/bash, it works ... so the updated question is, what is the /bin/sh equivalent of bash <(curl -sSL 'goo.gl/p1GPQw') 29165BE4-EA61-8228-9F33-A9B9DAD481A0 ./Info.plist as making users change this is another complication that can make the entire thing go sideways.
I tried to simplify the problem, for purpose of reproducibility:
This is 1.sh script:
#!/usr/bin/bash
echo echo Hello World
echo echo Today : $(date)
When run in /bin/bash, it works fine:
bash $ bash <(./1.sh)
Hello World
Today : Thu, Sep 22, 2016 2:32:19 AM
$
When run in /bin/sh it gives an error:
sh $ bash <(./1.sh)
sh: syntax error near unexpected token `('
sh $
But, the following should work fine even in /bin/sh:
sh $ bash -c "bash <(./1.sh)"
Hello World
Today : Thu, Sep 22, 2016 2:35:35 AM
sh $

Array bash script doesn't work

#!/bin/bash
ARRAYNAME=( 'time1' 'life' 'time2' )
echo ${ARRAYNAME[1]}
In the above code when i run my script as
$ sh ex1.sh
it gives an error message:
ex1.sh: 2: Syntax error: "(" unexpected
Why is this?
sh on your system is not bash.
Your "shebang" lines uses bash shell ("/bin/bash") but you're probably invoking another shell ("sh") invoking another shell to execute your script. Try this :
$ chmod 700 ex1.sh
This will make your script executable. Then run it :
$ ./ex1.sh

Resources