Tag Archives: ubuntu

file_name.sh: 3: Syntax error: “(“ unexpected [How to Solve]

An error was encountered

Execute the command $./example03. Sh error:
./example03. Sh: 3: syntax error: “(” unexpected
check the document

#!/bin/sh
#function hello
function hello(){
    echo "hello SXU."
}
#main
hello	
exit 0

Confirm again and again that there is no error.

Find the reason

Related to the actual shell version used
use the command LS - L/bin/* sh to print and view. For example:
you can see that SH is redirected to dash. Therefore, if./example.sh is executed, dash is used.

Solution:

bash example. Sh the first line of the script #/ Change bin/sh to: #/ Bin/bash, and then execute./example. Sh. The code is correct for standard bash, because Ubuntu/Debian uses dash instead of traditional bash in order to speed up startup. The solution is to cancel Dash: sudo dpkg reconfigure dash , and select no in the selection, choose one of the three methods to succeed.

The docker export container cannot be run after being imported: error response from daemon: no command specified

The docker export container cannot be run after being imported. An error is reported: error response from daemon: no command specified

According to the error message, the command can be run without specifying the command

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/ubuntu    latest              fb52e22af1b0        3 weeks ago         72.8 MB

[root@localhost ~]# docker run -itd docker.io/ubuntu:latest
7ce403eba8d89127395e057eb4d6cf7eb2374e40214ce6575a29e755b707ca23

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS               NAMES
7ce403eba8d8        docker.io/ubuntu:latest   "bash"              4 seconds ago       Up 3 seconds                            hungry_babbage
[root@localhost ~]# docker export -o test.tar 7ce403eba8d8

[root@localhost ~]# ls
anaconda-ks.cfg  test.tar

[root@localhost ~]# docker import test.tar test/ubuntu:v0.1
sha256:c3d604273769f7a74126b27f29c8cecd055fc18b10c943da0c0528dc28520a60

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
test/ubuntu         v0.1                c3d604273769        4 seconds ago       72.8 MB
docker.io/ubuntu    latest              fb52e22af1b0        3 weeks ago         72.8 MB

[root@localhost ~]# docker run -itd test/ubuntu:v0.1
/usr/bin/docker-current: Error response from daemon: No command specified.
See '/usr/bin/docker-current run --help'.

# add /bin/bash work
[root@localhost ~]# docker run -itd test/ubuntu:v0.1 /bin/bash
5b7dca448a1400716fa931463c2c314e0e59c7888fa77d5b182e72d911122966

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS               NAMES
5b7dca448a14        test/ubuntu:v0.1          "/bin/bash"         3 seconds ago       Up 2 seconds                            zen_varahamihira
7ce403eba8d8        docker.io/ubuntu:latest   "bash"              5 minutes ago       Up 5 minutes                            hungry_babbage

esp32:A fatal error occurred: Timed out waiting for packet header

Question

When I download the program to esp32 with Arduino IDE, the following error message appears:

My board is the following Board:

 

Causes and Solutions

The reason is that there is an error in the baud rate selection. The baud rate I selected is 921600 by default. In fact, 115200 should be selected. In this way, you can download normally after downloading again.

As shown in the figure below, it is successful.

 

 

Solution to “error: invalid environment block” when Ubuntu starts up

Solution to “error: invalid environment block” when Ubuntu starts up

1. Error status 2. Solution


1. Error status

When starting Ubuntu with grub, some errors are displayed below:

error: invalid environment block

Press any key to continue...

2. Solutions

Execute the following instructions:

sudo cd /boot/grub
sudo rm grubenv
sudo grub-editenv grubenv create
sudo grub-editenv grubenv set default=0

Now check whether it is feasible

grub-editenv grubenv list
# default=0

Restart again should have no problem.


thank you

Solutions to remote or adding SSH key errors

 

 

Method 1

ssh-keygen -R XX.XX.XX.XX  

Method 2

【1】 Delete the corresponding IP in known_ Hosts related information

vim /.ssh/known_ hosts

The problem is solved. The reason is that after the system is reinstalled, the remote connection is made again. After entering yes, this opportunity writes the information of the remote machine to/users/Wangdong /. SSH/known_ Hosts file, so if you reinstall the system remotely, you must clean up the machine first.

Error reporting using NVIDIA SMI

Error reporting using NVIDIA SMI:

NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running

This is a common problem, which often occurs in Ubuntu systems. The main reason is that the system kernel has been upgraded, resulting in the mismatch between the new kernel and the original graphics card driver

Solution 1:

Just execute two commands:

Sudo apt get install DKMS
sudo DKMS install – M NVIDIA – V 440.44 (440.44 indicates the driver version number)

Use the command ll/usr/SRC/to view the nvidia-440.44/ folder below. The version number varies from computer to computer
 

[Solved] ERROR: error loading sources list: The read operation timed out

During the installation of ROS platform under Ubuntu 20.04 system, an error is reported during the initialization of rosdep

rosdep update

Super times error

reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: error loading sources list:
	The read operation timed out

When you execute rosdep update according to the method in this article, there is still a timeout error, and you think of adding it directly in sources. List. D https://ghproxy.com/ Prefix, as follows:

Connect the mobile phone hotspot and open the terminal for execution

sudo vim /etc/ros/rosdep/sources.list.d/20-default.list

Modify list content

# os-specific listings first
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

# generic
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

Then run rosdep update to solve the problem.

ubuntu@ubuntu:~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
Add distro "galactic"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/ubuntu/.ros/rosdep/sources.cache

AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘ [How to Solve]

The error details are as follows:

Traceback (most recent call last):
  File "/usr/local/bin/evo_traj", line 5, in <module>
    import re
  File "/usr/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook
    if not enabled():
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
    import re
  File "/usr/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'

Original exception was:
Traceback (most recent call last):
  File "/usr/local/bin/evo_traj", line 5, in <module>
    import re
  File "/usr/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'

Problem analysis
this problem has not occurred before. It is suspected that the python iteration version conflict is caused by the update of Ubuntu system. It is recommended to turn off the automatic update of Ubuntu to prevent such problems. It takes a long time to solve some version conflict problems.

Solution:
the query found that pythonpath was set incorrectly. The configuration left by the previous use of python2 was saved in. Bashrc, resulting in python3 unable to find the correct enum location. After commenting out the relevant statements in bashrc, clear the $pythonpath variable:

 unset PYTHONPATH
 echo $PYTHONPATH

Then it can be used normally. Pythonpath is a multi-purpose configuration in python2. It is generally no longer needed after using python3.

[Solved] Error: Another program is already listening on a port that one of our HTTP servers is configured to

Question

    1. Step 1 run
supervisord  -c /etc/supervisor/supervisord.conf

Error

Error: Another program is already listening on a port that one of our HTTP servers is configured to

Solution:

ps -ef | grep supervisord

Turn off the 8079 process

kill -s SIGTERM 8079  

Solution results

supervisord  -c /etc/supervisor/supervisord.conf

No error is the best case, indicating that the process is started successfully

ros2 apt-get install error: E: Failed to fetch http://packages.ros.org…

version: foxy

apt install

sudo apt-get install ros-foxy-serial-driver 
[sudo] password for mi: 
Sorry, try again.
[sudo] password for mi: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  ros-foxy-serial-driver
0 upgraded, 1 newly installed, 0 to remove and 769 not upgraded.
Need to get 9,508 B of archives.
After this operation, 61.4 kB of additional disk space will be used.
Err:1 http://packages.ros.org/ros2/ubuntu focal/main amd64 ros-foxy-serial-driver amd64 0.0.6-1focal.20210423.022509
  404  Not Found [IP: 64.50.233.100 80]
E: Failed to fetch http://packages.ros.org/ros2/ubuntu/pool/main/r/ros-foxy-serial-driver/ros-foxy-serial-driver_0.0.6-1focal.20210423.022509_amd64.deb  404  Not Found [IP: 64.50.233.100 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Apt update error:

W: An error occurred during the signature verification.
 The repository is not updated and the previous index files will be used.
 GPG error: http://packages.ros.org/ros/ubuntu focal InRelease: The following signatures were invalid: EXPKEYSIG F42ED6FBAB17C654 Open Robotics <[email protected]>

Solution:

 curl http://repo.ros2.org/repos.key | sudo apt-key add -

Ubuntu: Redis starts the project Error [How to Solve]

redis.exceptions.ResponseError: MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

Cause: redis snapshot forced to close, resulting in the problem of not being able to persist
Solution.
1. Avoid this problem by setting the stop-writes-on-bgsave-error value to no.

Through the redis command line directly to change.
Go to the redis command line and execute: config set stop-writes-on-bgsave-error no

2. Change the stop-writes-on-bgsave-error value to no by modifying the redis.conf configuration file (same effect as 1)

By modifying the redis.conf file modify.


Finally, remember to restart redis: /etc/init.d/redis-server restart (If restarting doesn’t work, try stopping redis first [/etc/init.d/redis-server stop] and then starting it again [/etc/init.d/redis-server start].