I'm trying to test the supposed flaw in OS X Lion, of how unprotected the password is, on my own computer (from this article). But when I enter the code the in terminal that is supposed to extract the password hash:
$ dscl localhost -read /Search/Users/<root user>
I get this:
-bash: syntax error near unexpected token `newline'
is there any way to get around this?
When you see <xxx> in a command-line command, it typically means "substitute something here". For example,
$ ls <file>
doesn't mean to literally type in ls <file> in your Terminal, but to type in ls followed by some filename.
In this case, they want you to substitute the name of your root user for <root user>. For most machines, that is simply root.
In Azure bash shell in case your scenarios is this:
$ az webapp stop \
--resource-group learn-f69ca399-f99b-4950-84a6-bda8206c6ba0 \
--name <apiyoachola>
bash: syntax error near unexpected token `newline'
This should solve it
$ az webapp stop \
--resource-group learn-f69ca399-f99b-4950-84a6-bda8206c6ba0 \
--name apiyoachola
Related
This question is very similar to How do I pass an absolute path to the adb command via git bash for windows?, but the answer to the latter does not work in my case, because //subscriptions/... is not a valid Azure resource Id.
Given:
VMS=( \
"/subscriptions/d...8/resourceGroups/xyz/providers/Microsoft.Compute/virtualMachines/cks-master" \
"/subscriptions/d...8/resourceGroups/xyz/providers/Microsoft.Compute/virtualMachines/cks-worker" \
)
I would like to start the VMs using the following command line:
az vm start --ids ${VMS[#]}
However, it does not work:
~$ az vm start --ids ${VMS[#]} | nocolor
ERROR: invalid resource ID: C:/Program Files/Git/subscriptions/d...8/resourceGroups/xyz/providers/Microsoft.Compute/virtualMachines/cks-master
~$
(nocolor is an alias that drops the ansi color sequences using the approach described in https://superuser.com/a/380778/9089)
The aforementioned SO post suggests to prepend another /, which works for a file path, but does not work for an Azure resource Id:
~$ VMS=( "//subscriptions/d...8/resourceGroups/xyz/providers/Microsoft.Compute/virtualMachines/cks-master" "//subscriptions/d...8/resourceGroups/xyz/providers/Microsoft.Compute/virtualMachines/cks-worker" )
~$ az vm start --ids ${VMS[#]} | nocolor
ERROR: invalid resource ID: //subscriptions/d...8/resourceGroups/xyz/providers/Microsoft.Compute/virtualMachines/cks-master
~$
So, what do we do, besides using Powershell or WSL2?
You can use the MSYS_NO_PATHCONV=1 flag at the beginning of the az cli command.
In your case:
MSYS_NO_PATHCONV=1 az vm start --ids ${VMS[#]}
See:
https://github.com/Azure/azure-cli/blob/dev/doc/use_cli_with_git_bash.md#auto-translation-of-resource-ids
How to stop MinGW and MSYS from mangling path names given at the command line
I have an exe file which executing some commands in docker container (ubuntu) that should make a build and run application. In some step I need to make a copy of dist file and command looks like this
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v //f/bigaboo/repos/ledger://f/bigaboo/repos/ledger --workdir=//f/bigaboo/repos/ledger bbcli_executor bash -c "cp ./public/index.php.dist ./public/index.php"
When I just run this command in the terminal all works well but if it's under exe control I have this output
./public/index.php.dist: -c: line 1: unexpected EOF while looking for matching `"'
./public/index.php.dist: -c: line 2: syntax error: unexpected end of file
2022/10/31 22:14:42 Failed to create index.php`. Error -> exit status 2
Looks like script don't recognize strings under exe.
I've tried to wrap cp in '',`` and \x22 but I've got the same result but with different symbols also I've tried to change encoding also without success :(
I'm trying to install Netdata in my aws beanstalk instances. I created a config file in my .ebextensions folder
container_commands:
00install:
command: "bash <(curl -Ss https://my-netdata.io/kickstart.sh) --dont-wait"
ignoreErrors: true
When the command gets ran on deploy beanstalk logs this error.
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `bash <(curl -Ss https://my-netdata.io/kickstart.sh) --dont-wait'
I had no idea what <() meant so I looked it up and saw it was process substitution. From what I understood process substitution can be rewriting using plain pipes.
For example
more <( ls /usr/bin )
Could be
ls /usr/bin | more
In my command I'm also passing in flags so I was having issues gettin the piped version of the command working.
NOTE: The root problem is beanstalk telling me its confused about the parenthesis. My solution was just transforming the command to use regular pipes. However, if anyone knows just how I write this command on the beanstalk config to get it working that would be awesome.
The following line fails when run in a alpine docker container:
toDelete=( $(curl --silent $url/_cat/indices\?format=json | jq -r '.[].index | select(startswith('\".kibana\"'))') )
The following error message appears:
run.sh: line 1: syntax error: unexpected "("
When I run the command in the terminal on my mac, everything works properly. The brackets are added so that the result (variable toDelete) is interpreted as array and can be looped through with a for loop like so:
for index in "${toDelete[#]}"; do
curl -X DELETE $url/$index
done
Any help in how to solve this problem is appreciated!
Marking down the answer.
The issue was with the interpreter.
worked after making the below change.
["/bin/ash", "run.sh"]
the passed one was
["/bin/sh", "run.sh"]
I am trying to execute
sudo -su db2inst1 /opt/ibm/db2/V9.7/bin/db2 force application (1995)
but I get this error:
bash: syntax error near unexpected token `('
However,
sudo -su db2inst1 id
gives me correct output. So it must be something about the ()
If I try
sudo -su db2inst1 /opt/ibm/db2/V9.7/bin/db2 force application \(1995\)
I get
/bin/bash: -c: line 0: syntax error near unexpected token (' \ /bin/bash: -c: line 0: /opt/ibm/db2/V9.7/bin/db2 force application (1995)'
Running /opt/ibm/db2/V9.7/bin/db2 force application (1995) as db2inst1 user gives me the same error, but running
/opt/ibm/db2/V9.7/bin/db2 "force application (1995)"
works fine
The right syntax is
sudo -su db2inst1 '/opt/ibm/db2/V9.7/bin/db2 "force application (1995)"'
NOTE: While this answer seems to have been correct at the time [sudo was changed later that same year to add extra escaping around characters in the arguments with -i and -s], it is not correct for modern versions of sudo, which escape all special characters when constructing the command line to be passed to $SHELL -c. Always be careful and make sure you know what passing a command to your particular version of sudo will do, and consider carefully whether the -s option is really needed for your command and/or, if it would, if you'd be better served with sudo sh -c.
Since you've got both the shell that you're typing into and the shell that sudo -s runs, you need to quote or escape twice. Any of the following three would have worked with this now-ancient version of sudo:
sudo -su db2inst1 '/opt/ibm/db2/V9.7/bin/db2 "force application (1995)"'
sudo -su db2inst1 '/opt/ibm/db2/V9.7/bin/db2 force\ application\ \(1995\)'
sudo -su db2inst1 /opt/ibm/db2/V9.7/bin/db2 force\\ application\\ \\\(1995\\\)
Out of curiosity, why do you need -s? Can't you just do the following?
sudo -u db2inst1 /opt/ibm/db2/V9.7/bin/db2 'force application (1995)'
sudo -u db2inst1 /opt/ibm/db2/V9.7/bin/db2 force\ application\ \(1995\)
Try
sudo -su db2inst1 /opt/ibm/db2/V9.7/bin/db2 force application \(1995\)