Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
150 views

How to get the jdk install path using shell programmatically when dual jdk are installed in RHEL?

I have a list of servers in which I need to find the jdk-8 install location programmatically. A few of the servers are having single jdk installation which makes it easier to find the install location ...
JCDani's user avatar
  • 317
0 votes
0 answers
130 views

Rhel: Get machine ID and then replace it in file

I have machineid in /etc/machine-id I want to replace string id=machineid in file /var/somefile.conf with the "new id". How can I do this easy with one command line?
fixern256's user avatar
0 votes
1 answer
396 views

python3/bash + how to automate creation of disk partitions in Linux

here is example from our rhel server machine lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 20G 0 disk /data/sdb sdc 8:32 0 20G 0 ...
Judy's user avatar
  • 1,871
0 votes
0 answers
326 views

Shell script execution is failed with error " No such file or directory"

I Have written a shell script which simply show the swap memory usages from processes. I have executed the script at my end successfully, but when I share this with client to execute it is getting ...
Suyog's user avatar
  • 21
1 vote
2 answers
627 views

Linux Bash, Test command, why [ 0 -ne 0 ] is false instead of true?

When using test command in Linux Bash and numeric comparison between "Zero" equal to "zero" fetches an exit code 0 through echo $? $[ 0 -eq 0 ] $echo $? 0 However, when testing ...
Anand's user avatar
  • 31
0 votes
1 answer
78 views

How to print list of strings in a pop up window and save the strings in a file with time stamp

When I run below script, it reads a report.txt file and whenever a message is matched in the file a pop up window will come with the message. How whiptail can be used out of for loop so that pop up ...
Fatima's user avatar
  • 9
1 vote
1 answer
717 views

bash/shell - How do I get the group name of a directory on RHEL and save it to a variable?

I'm working on a script to create users and grant them access to a directory, but they have to be added to the group that has permissions on the directory. I noticed that if I do a stat on the ...
BuddyLee's user avatar
1 vote
0 answers
306 views

Unable to get Compliant state for OS policy assignment on GCP console

I created a RHEL7 VM and a OS Policy assignment with a simple config. Here is the YAML I'm using to validate. Below is the same shell script used in yaml for reference: export num=$(stat --format '%a' ...
Utkarsh Sharma's user avatar
2 votes
0 answers
331 views

"ssh -q" pbrun exec last login still showing up even with .hushlogin

I'm running the below script on RHEL 7.9 and after connecting to the remote machine and execing pbrun, the last login message is getting displayed and sometimes it interferes with the command which is ...
tom's user avatar
  • 21
1 vote
1 answer
2k views

getting "grep: write error: pipe broken" when command executed through application installation

Below is the command which is executed when I install the application(this line written in one of the script of our application). PASS=strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 10 | tr -d ...
shubham's user avatar
  • 21
0 votes
2 answers
54 views

bash + how to set cli PATH with version in sub folder

Under /usr/hdp folder we can have only one the following sub-folders 2.6.5.0-292 2.6.4.0-91 2.6.0.3-8 example ls /usr/hdp/ 2.6.5.0-292 current stack file.txt I want to use the following cli, and $...
jessica's user avatar
  • 2,570
0 votes
1 answer
56 views

Looping through awk command using bash in RHEL

I am trying to loop through the output of an awk command in bash. I saved the output to a variable and when I loop through, all of the output is saved as one long string instead of each one their own ...
ImACarrot's user avatar
4 votes
1 answer
849 views

How to find a YAML value from Bash using PyYAML

I'm testing the feasibility of using PyYAML v3.12 within a RHEL7 environment to parse the contents of moderately complex YAML config files, by feeding it a key and getting the keypair value back. The ...
MissCatAssTrophy's user avatar
0 votes
0 answers
251 views

Cannot create and write content in a file from shell script

I am creating a shell script on Linux machine. I am doing the following lines of code: RESPONSE_FILE='/var/tmp/abc' chmod 777 '/var/tmp' chown root '/var/tmp' touch $RESPONSE_FILE logger "[INFO] ...
Arbaaz Mandlik's user avatar
0 votes
2 answers
928 views

How to perform grep on curl within for loop?

I have created an array uisng the command IFS=', ' read -r -a array <<< "$(command)" The array has values: abc001 abc002 abc003 I want to loop through the array and run a curl command on ...
meallhour's user avatar
  • 15.5k
0 votes
1 answer
207 views

How to fetch output of command into a variable? [duplicate]

I am trying to run a command and storing the values in a list list = `sed -n 's/^abc//p' /etc/filename` I am getting an error command not found while running the above command. However, when I ...
meallhour's user avatar
  • 15.5k
0 votes
2 answers
87 views

To exit out of the code if expect condition not met RHEL

I have written a small code using expect in Red Hat Linux 8 to check if a host is reachable using ICMP Ping. My intention is if the destination is not reachable , then the execution should break....
newuser's user avatar
  • 69
2 votes
1 answer
2k views

How to use -regex in the find command on Linux command line

The objective is to find and list anything with "messages" and/or "error.log" etc.. in the beginning then list both "messages.1..99" and "error.log.1..99" using regular expressions. This command ...
Collin Budrick's user avatar
0 votes
1 answer
96 views

How can I extract the OS version of a remote VM and set it as an environment variable on the remote VM and also to use further in the expect script?

I am trying to fetch the OS version of a remote VM and add it as an environment variable on the same vm and also use the fetched value further on the host vm from where the expect script is being ...
Ravi Kiran's user avatar
0 votes
3 answers
953 views

How to simplify an if-else statement matching IP address

I have the following If-Else statement which I want to simplify. if [[ "$IP" == 192.* ]] || [[ "$IPAddr" == 193.* ]] then data="correct data set" fi I need to include more of [[ "$IP" == 192.* ...
meallhour's user avatar
  • 15.5k
0 votes
1 answer
1k views

RHEL RPM spec post installation %post not sourcing shell script

I am trying to source a shell script in the root environment (as I am doing installation as root) after successful installation of a rpm in RHEL7.4 box The rpm spec %post section is as follows: %...
Ibrahim Quraish's user avatar
1 vote
2 answers
3k views

Permanently set environment variables for Multiple users

Java build machine is on Redhat 7.5 to run mvn clean package deploy for building Java code. Multiple users login with their username to this build machine, to build Java code. To permanently set ...
overexchange's user avatar
1 vote
2 answers
3k views

Shellscript to monitor a log file if keyword triggers then run the snmptrap command

Is there a way to monitor a log file using shell script like tail -f /var/log/errorlog.txt then if something like down keyword appears, then generate SNMPTRAP to snmp manager and continues the ...
vignesh's user avatar
  • 43
2 votes
1 answer
662 views

Efficient method to parse large number of files

I've incoming data which will be in range of 130GBs - 300GBs containing 1000's (maybe millions) of small .txt files of size 2KB - 1MB in a SINGLE folder. I want to parse them efficiently. I'm looking ...
Marcos's user avatar
  • 895
0 votes
1 answer
147 views

Discrepancy between df -h and ll -h returned information

everyone! df -h shows that a disk is full (used 100%). But when I use ll -htotal size of files almost 2%. Can someone explain what happens?
Meow Meow's user avatar
  • 666
1 vote
0 answers
286 views

cygwin xterm to open multi session from script

I have .ksh script with below commands to open multiple session on different server but not able to execute file parallel same time.any help ? xterm -e ssh appuser@appserver1; cd /usr/bin/; ./...
S.Modi's user avatar
  • 15
1 vote
2 answers
181 views

How to run multiple, distinct Fortran scripts in parallel on RHEL 6.9

Let's say I have N Fortran executables and M cores on my machine, where N is greater than M. I want to be able to run these executables in parallel. I am using RHEL 6.9 I have used both OpenMP and ...
user1887919's user avatar
2 votes
2 answers
3k views

Adding YUM Repos With Variables

I am trying to add a YUM repo from the command line like so cat > /etc/yum.repos.d/my_stable_repo.repo << EOF [my_stable_repo] name=Stable Repo baseurl='https://myurl/$releasever/stable/...
Ryan's user avatar
  • 688
-1 votes
2 answers
3k views

Why do I get 'permission denied' after using ./file2 in Linux? [duplicate]

For example I have a file named file2 that echoes something. So in the shell, after typing this # ./file2 It shows Permission denied Where am I wrong here?
Rushabh Dudhe's user avatar
0 votes
2 answers
1k views

RHEL Environment Variable Path To Mongo Shell

I have installed mongodb in one of our environments & this has been done using MongoDb Operations Manager. Though i have my PATH variable set correctly i'm unable to connect mongo shell with my ...
S.D.'s user avatar
  • 1,191
7 votes
1 answer
243 views

Why bash4 expands curly braces differently?

One of legacy system got upgraded to bash4 and most of its scripts stopped working. I've narrowed it down to how a curly brackets are expanded within a <(cmdA ...|cmdB ... file{1,2}|cmdZ ...). To ...
Vlad's user avatar
  • 1,187
0 votes
1 answer
2k views

How to select an option automatically from a prompt message in shell script?

when i run my script manually it prompts a message to select YES or NO . I am automating this part in shell scripting, how to automatically select YES script.sh - if i run this it should take the ...
Subrat Sahoo's user avatar
67 votes
6 answers
81k views

Install ONLY mongo shell, not mongodb

As mentioned above, I need to install only the mongo shell on a RHEL instance (machine A). I have a mongodb server on a separate instance (machine B) and need to connect to that from A to run ...
Rijumone's user avatar
  • 822
0 votes
1 answer
91 views

How to list a file by filename as a date?

I have list of filename which have format like this _ddmmyyyy.txt for example : filea_01122016.txt filea_02122016.txt filea_03122016.txt filea_04122016.txt filea_05122016.txt And I want to compress ...
Cemox's user avatar
  • 43
0 votes
0 answers
86 views

Trying to tee inside bash script works on RHEL 6.7 but not on RHEL 6.8

I have the following bash script: #!/bin/bash exec &> >(tee -a /tmp/file1.log) echo "1" echo "2" echo "3" It runs on a RHEL 6.7 host and what it does is to print 1 2 3 to both stdout and /...
mauroformigoni's user avatar
1 vote
4 answers
5k views

Bash: Read in file, edit line, output to new file

I am new to linux and new to scripting. I am working in a linux environment using bash. I need to do the following things: 1. read a txt file line by line 2. delete the first line 3. remove the middle ...
pskelly's user avatar
  • 13
0 votes
1 answer
203 views

How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?

I have a small application that needs to run continuously in the background. The program is able to setup directory monitoring services, HTTPS listeners, and other services that need to remain running ...
Adam P.'s user avatar
  • 75
4 votes
2 answers
626 views

Restrict kill commands when running jar file using a shell script

I have a jar file which is a program which accept user input and processes it. I am running this jar file using the below shell script: PR=`basename $0` cdt=`date +'%H:%M:%S %d/%m/%Y'` cd $HOME/...
lang_android's user avatar
1 vote
2 answers
14k views

How to use amqsput command in shell script to push data into a queue?

I am using following command to push some data into a Message Queue. amqsput QUEUE_NAME QUEUE_MANAGER_NAME Then after console available I push my required data. (just shown in the screenshot, I will ...
74H1R's user avatar
  • 3,504
0 votes
2 answers
700 views

How to find commands ran in a particular day from a particular username

I am able to find out from secure log that who logged in from where using ssh. And the last command also proved that. Is there any why to find out what were the commands run in that ssh session?
Biswadip Dey's user avatar
-1 votes
2 answers
166 views

get java installation path using shell script in rhel

I have to automate a process in which i need to install java on RHEL 7, using rpm package and then update the security jars later on the installed location. Once i execute the java rpm, how would i ...
user05209's user avatar
0 votes
2 answers
748 views

redirect stdout and stderr to different file under sandboxing in linux

I have an Test.cpp which is run under sandbox(RHEL7): Test.cpp content: #include<stdio> int main(void) { int a = 1/0; return 0; } compile it using gcc(4.8) Test.cpp which produces the a....
Bhuvan's user avatar
  • 4,167
0 votes
2 answers
51 views

Scripts works fine in CentOS but not on RHEL5

Below script works fine on CentOS but not on RHEL5: #!/bin/bash read -p "enter your value:" ip if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] then echo "valid" else echo "invalid" ...
Sanchit J R's user avatar
29 votes
2 answers
54k views

why do I get "Suspended (tty output)" in one terminal but not in others?

Apparently I've done something strange/wrong in a tcsh shell, and now whenever I start an application in the background which prints to stdout the application is suspended (stopped). Weird thing is, ...
oliver's user avatar
  • 6,751
0 votes
2 answers
351 views

DSH (dancer's shell) hangs when getting tail -f logs

I'm using dancer's shell dsh (http://www.netfort.gr.jp/~dancer/software/dsh.html.en) to send a tail -f command to 6 machines. I was hoping to use this to view a merged log from a service which ...
k-den's user avatar
  • 853
1 vote
1 answer
4k views

Unable to set just year with Linux date command [closed]

For some reason I fail to update year only using date command date Tue Mar 4 20:15:42 IST 2014 date '+%Y' -s '2013' date Tue Mar 4 20:13:01 IST 2014 I tried it on both RedHat and Ubuntu... NTP ...
Gregory Danenberg's user avatar
2 votes
1 answer
819 views

How to use environment variable declared in /etc/profie into script running through monit?

Environment variable declared in /etc/profile: export MYNAME=rhel Content of script which is running from monit is [/tmp/printmyname.sh]: echo "My Name is: "$MYNAME >> /var/log/...
Rambo's user avatar
  • 35
-1 votes
1 answer
40 views

Im stuck in RHEL 6.3

What about ?? if -f $LOCAL_EVENT_LOG_FTP_TEMP del $LOCAL_EVENT_LOG_FTP_TEMP else echo Event Log Backup Module not Activated. fi; Is there any mistakes?
Erynne's user avatar
  • 17
0 votes
1 answer
232 views

RHEL 6.3 shell scripting

What is wrong with this? if [ ! -d "$LOCAL_WORKING_DIR" ] then mkdir "$LOCAL_WORKING_DIR" cd "$LOCAL_WORKING_DIR" else cd"$LOCAL_WORKING_DIR" fi Errors : syntax error near ...
Erynne's user avatar
  • 17
-2 votes
1 answer
882 views

I just started learning Scripting in Shell Script, RHEL 6.3 [duplicate]

How to write in Terminal RHEL 6.3 in a proper way? If not exist LOCAL_WORKING_DIR LOCAL_EVENT_LOG_WORKING_DIR mkdir LOCAL_WORKING_DIR LOCAL_EVENT_LOG_WORKING_DIR ???? I have tried with this but ...
Erynne's user avatar
  • 17