You are not logged in.
Hi I am Rupesh from India and I have a system with intel i3 10th gen processor and Asus prime H 510 m-e motherboard. I have installed Arch Linux directly from Arch Linux live image. Everything is working fine except few issues related to bash and other shells.
Previously I have installed Arch Linux using Arch Linux gui installers like
Arch Linux gui
Arch Linux calameries installer alias ALCI
Black arch Linux slim
All of them worked fine but I thought to install Arch Linux using the official live image provided by Arch Linux website.
Yesterday I have installed Arch Linux through booting official live image and using the script arch-install. After installation of kernel and some main packages post processing stopped abruptly. I mean bootloader was not installed as I got error as efibootmgr not found. /etc/fstab was not created.
I have manually installed efibootmgr and after that executed grub-mkconfig and grub-install. I ran genfstab tool to generate fstab file.
At present I am able to login to my Arch Linux system. After that I have installed desktop environments like gnome and plasma.
I am able to boot into my system and login through sddm display manager.
Still I think that something is not configured properly.
I have created a non root user through useradd utility and started working through it instead of root account.
In my non root user account I have opened .bashrc file but unfortunately not found PATH variable and other settings. I am providing the bashrc file so that you can correctly find what's wrong.
I want to install other packages related to mediainfo, variety, x265, x266, aom, ffmpeg etc., which are upto 100.
So I have ran the following commands like
pacman -Ss mediainfo >> search.txt
pacman -Ss ffmpeg >> search.txt
I have found some description about mediainfo ffmpeg and others including package names in search.txt
Finally I have created a text file called input.txt which consists of words related to what I want like mediainfo variety etc.,.
I have created a small bash script which reads all the lines present in input.txt and search for packages related to them.
The script consists of the following line with in while loop
pacman -Ss $name >> search.txt
Here name is the variable which is the line read from input.txt file.
The pacman search command is running properly when I run directly in a terminal emulator like konsole but the same pacman search command is not working in shell script.
For example I want to search for ffmpeg in package database when I issue the command directly in terminal emulator I am able to get correct results.
I have entered the following command in terminal emulator and got the results what I want.
pacman -Ss ffmpeg >> search.txt
I have created a temporary script with name script.sh and placed the above line in it and executed this particular script in terminal emulator but unfortunately search.txt is empty.
I am providing the contents of bashrc and search scripts below.
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
alias grep='grep --color=auto'
PS1='[\u@\h \W]\$ '
#!/bin/bash
while read name; do
echo $name
pacman -Ss $name >> search.txt
done < input.txt
What I want to say finally is pacman search command and output redirection are working fine in terminal emulator but not working in script execution.
However I have installed all the packages what I want but I can't understand why pacman search command and output redirection are not working in script execution.
Kindly try to suggest is there anything else to alter for working the system fine and in particular bash and scripting. If you want I am ready to provide any diagnostic information to you.
Regards,
Rupesh.
Last edited by rupeshforu3 (2024-03-20 13:53:18)
Offline
First, I suspect you'll get far more help if you focus on the issue you really want help with. You've included a whole lot of irrelevant information about your background and history. Then you have comments about PATH variable and your bashrc... is there a question there? Your users bashrc would not typically include any PATH settings.
Then for the actual issue, you don't provide any of the necessary information. Your script does not search for "ffmpeg" as you suggest, rather it searches for a line from input.txt. Post the actual input.txt if you want help with that script. Also post the full output of that script.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
...
#!/bin/bash while read name; do echo $name pacman -Ss $name >> search.txt done < input.txt
What I want to say finally is pacman search command and output redirection are working fine in terminal emulator but not working in script execution.
...
I have a couple of suggestions:
1. It is good form, on your read, use the option "-r" (do not allow backslashes to escape any characters). I would also consider quoting variables during parameter expansion.
2. Use full path for commands. Check path - "type -a pacman".
3. Check the return code of commands
# option 1
echo "${PATH//:/$'\n'}"
echo /usr/bin/pacman -Ss "$name"
/usr/bin/pacman -Ss "$name" && echo good || echo bad
# option 2
echo "${PATH//:/$'\n'}"
echo /usr/bin/pacman -Ss "$name"
/usr/bin/pacman -Ss "$name"
rc=$?
if (( rc != 0 )); then
printf -- 'Error: %s\n' $rc
fi
4. For debugging, after the shebang (#!/bin/bash), add the line "set -x" or "set -xv".
NOTE: Either review the man page for bash or on the command line type "help set" for details.
Offline