1
vote
1answer
22 views

PID of process causing error

I have this script: #!/bin/bash # -> dump.$pid ulimit -c unlimited # trap ERR set -o errexit # also trap error in the middle of a pipe (1) # otherwise it will only trap the error on (2) set -o ...
4
votes
3answers
381 views

Why can't I `tail -f /proc/$pid/fd/1`?

I wrote a simple script which echo-es its PID: #/bin/bash while true; do echo $$; sleep 0.5; done I'm running said script (it says 3844 over and over) in one terminal and trying to tail ...
-5
votes
0answers
28 views

Print lines if lines across four files does not have either Partially Successful or Successful Full [closed]

Hi I have 4 files like below each file has one week information, I would like to print lines if lines across four files does not have either Partially Successful or Successful Full corresponding to ...
-1
votes
0answers
20 views

Become root after login via plink from Windows host

I m trying to connect to a linux server from Windows host via plink. I couldnt figure out how to become root after logon. I have to login with ordinary user first as I can't change config of the ...
0
votes
0answers
11 views

Determin if the currnet terminal has a dark or light theme [duplicate]

I have several (Bash) scripts that uses ASCII color codes. They look good on my dark themed terminal, however on my colleagues light themed terminal the colors I selected don't look that good. Is ...
0
votes
0answers
25 views

Can't access GPIOs when switching to systemd, but why?

I'm using this ARM AT91 Sam9x5ek Embedded Device, with my Linux Images made by a Buildroot. Usually my init-system is Busybox, now I changed it to systemd. Since then I can't access the GPIO anymore, ...
1
vote
3answers
78 views

Network statistics on linux

I am trying to write a small script to gather network statistics on my Linux system. Is there any way I can do this? What I'm after is live stats on current network throughput. I have done some ...
2
votes
0answers
26 views

Tmux log output [duplicate]

Im looking for a solution to an issue regarding tmux. One of my scripts ns2server stopped working recently when running start (using tmux) but not in debug mode (not using tmux). I found that using ...
0
votes
1answer
45 views

How to evaluate a variable length in shell script?

I want to write a shell script, in which it will call different command according to the variable length. But I didn't figure it out yet. My unwork script is here: for i in n5 n25 if ${#i} == 2; ...
0
votes
2answers
79 views

how to remove all double quotes from csv except specific field

I want to remove all double quotes from my csv but not the fourth field (because the four fields represent PATH of file) Please advice how to implement this by sed or awk or perl one liner , etc ...
3
votes
1answer
28 views

awk + gsub + how to work with all kind of characters

The following awk command target is remove spaces and unnecessary quotes from CSV file and only from single words between separators awk 'gsub(/("[ ]+|[ ...
0
votes
0answers
37 views

bash script loses readonly value after first time thru loop

I have a bash script which seems to lose the value of the readonly constant after the first time thru the for-in loop. For example: #!/bin/bash readonly DIR="./groups/" for output in "${array[@]}" do ...
2
votes
1answer
48 views

Fetching Remote Windows System Information From Linux Server

I need a script/command that would fetch Windows System Information (Host Name,User Name, Domain, OS Info, Hardware Info, Memory Info, processor Info, etc) by running it on a Linux Server (RHEL 6.5 ...
3
votes
1answer
74 views

Is there a way to pass a variable from an awk statement to a bash function as an argument? [closed]

I am trying to look a for some specific values from (such as 1 or 4 and 2 or 3) a text file using an awk statement in a bash script. If this value is found in the file (within the awk statement), then ...
5
votes
1answer
74 views

Linux: $SSH_CONNECTION is set even without SSHing to the server

I have a remote server and I am writing a script in the server and want it to fire only when I SSH. I thought of using the $SSH_CONNECTION and $SSH_TTY for this purpose. I found out that when I have ...
4
votes
1answer
102 views

PS: what does “ps -o comm= -p $PPID” do

I have a script which does ps -o comm= -p $PPID. The explanation says this gets the parent process name. From the man page I found out -o means user defined format, comm means command and -p means ...
-4
votes
2answers
61 views

How to print numbers horizontally? [duplicate]

I would like to print something as 5,4,3,2,1. This is my program, but it prints the numbers vertically. numbers=5 i=1 while [ "$i" -le "$numbers" ] do echo “$i” i=$(( $i + 1 )) done Do you have ...
3
votes
1answer
45 views

Openbox pipe-menu script error

This is the weirdest thing. The script works when run from the shell with no problems. When I run it as an Openbox pipe-menu I get the error "Invalid output from pipe-menu". After playing around with ...
2
votes
2answers
97 views

CSV file + set CSV parameters and values in bash script

I have the following CSV file: Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa 1000,"1 0 0 1",1002,1002,1003,1004,1005,"1 0 ...
0
votes
0answers
32 views

Calculate Total disk i/o by a single process [duplicate]

I am looking for some tool that will dump total disk I/O by a single process after it ends. So far my finding is :- iotop= It shows i/o per process in real time but does not give total after process ...
2
votes
1answer
83 views

Bash script and processes

I have created a bash script for use with a graphical bar in Linux, however the script seems to spawn too many processes. The script: #!/usr/bin/bash executable="/usr/local/bin/bar" monitor=${1:-0} ...
3
votes
4answers
184 views

How to cut everthing until a specific word / after a find in a script

Hello I try to get the output of files from today wich contains ERROR. I use this to find the files I want: find /home/user/logfilesError/ -maxdepth 1 -type f -name "gandalf_*"\ -daystart -mtime ...
1
vote
1answer
45 views

Bash loop new user

I have to create 20 users on 10 servers. I want to create a script that will create 20 users for me on the server (that's easy with useradd) and encrypt the password. I have my variable $crypt=perl ...
5
votes
2answers
485 views

How to find out if httpd is running or not via command line?

I'm working on a small control panel for my server. I need a command that will say if httpd is running or stopped. Will probably be using the same code for other services as well.
0
votes
1answer
59 views

Is there a way of copying only directories and not files in bash? [closed]

I want to copy only directories from a folder on a remote server to my server. Is that possible? Here is the code I have so far but it copies files and folders: scp -rq ...
1
vote
1answer
37 views

copy mp3 to a target directory maintaining directory structure and deleting files when copy complete

Found this answer here for copying files and keeping directory structure. copy files find . -name '*.xxx' -exec cp -iv --parents -t /path/to/target_dir {} + Is there an easy way to maintain the ...
1
vote
2answers
153 views

Changing user to root when connected to a linux server and copying files

My script is coded in a way that doesn't allow you to connect to a server directly by root. This code basically copies files a server to my computer and it works but I don't have access to many files ...
5
votes
3answers
2k views

Prompt user to login as root when running a shell script

The problem I am getting is, when I enter the command, su - root at the beginning of my shell script file, it prompts the user to enter the password and then does NOT continue with the rest of the ...
0
votes
2answers
47 views

What are the specific naming conventions for variables in bash shell scripting language? [duplicate]

Is it the same convention as those used in known programming languages such as Java and C? I'm trying to create a lot of variables and I want it to start with a number, but I'm not sure if it's okay.
1
vote
4answers
109 views

How to set the process won't be terminated when the terminal stops

[Edit] Make it simple. I invoked java xxx... on Machine A using putty to connect from Machine B. However I cannot reach Machine B. How can I connect Machine A from Machine C to set the running ...
3
votes
5answers
219 views

Listing directories based on size from largest to smallest on single line

I can use the following command to get a list of directories and their sizes and sort them from largest to smallest (in the example I renamed the directories to numbers to make this easier to ...
2
votes
0answers
513 views

How to use rsync with GNU parallel?

I am using scp to copy the files in parallel using GNU parallel with my below shell script and it is working fine. I am not sure how can I use rsync in place of scp in my below shell script. I am ...
2
votes
1answer
55 views

Trying to compare a variable that is multiline in a if comparison

Here is the current file I am running: #!/bin/ksh -x export BIN_DIR="../../env" . $BIN_DIR/vdenv.ksh success="DROP CREATE TABLE GRANT" $worker_dir/runsql.ksh ddl X X > chnl_avt_v1.log ...
1
vote
1answer
83 views

How to copy in two folders simultaneously using GNU parallel by spawning multiple threads?

I am trying to copy files from machineB and machineC into machineA as I am running my below shell script on machineA. If the files is not there in machineB then it should be there in machineC for ...
2
votes
3answers
876 views

How to launch two threads in bash shell script?

I am trying to copy files from machineB and machineC into machineA as I am running my below shell script on machineA. If the files is not there in machineB then it should be there in machineC for ...
0
votes
3answers
108 views

Applying different permissions to files vs. directories

Sunny answered the question above in this post, The answer was given as No need for scripts. // Directories: find . -type d -exec chmod XXX {} \; // Files: find . -type f -exec chmod ...
0
votes
2answers
177 views

Bad configuration option: ControlPersist while scp with control master?

I am using SCP with ControlMaster to copy the files but somehow I am getting this error back - command-line: line 0: Bad configuration option: ControlPersist command-line: line 0: Bad configuration ...
3
votes
2answers
115 views

Identify partition by mount point

How can we identify what partition a filesystem is mounted on in Linux when the partition is not directly referenced in df output? For example, our system's fdisk output is: Device Boot ...
1
vote
2answers
107 views

How to properly launch a program and make possible to redirect its running output (stdout and stderr) at a later stage?

The problem is quite simple: I find useful to have the possibility to switch on (and off) the output of some running program in each moment I need. To be more precise I want to be free to redirect ...
2
votes
3answers
97 views

How to split the array in set of five files and download them in parallel?

I am trying to copy files from testMachineB and testMachineC into testMachineA as I am running my shell script on testMachineA. If the file is not there in testMachineB, then it should be there in ...
2
votes
1answer
137 views

No password prompt when using rsync remotely?

I have a bash script that executes rsync transfers to a remote location, and every time I execute the script I get asked for a password. Is there a way to avoid this? This is the command I use: ...
3
votes
1answer
626 views

Why does the filename contains question marks when I run a script on my remote machine?

I have a tiny script that simply fetches the current date, runs a PHP script and redirect the output (and errors) to a filename containing the current date. DATE=$(date +"%Y%m%d") ...
0
votes
1answer
66 views

where does history timestamp stored before i enable it

I tried to set timestamp for history. My first attempt was do export EXTENDED_HISTORY=ON command, and it seems like doesn't work. Then i do echo 'export HISTTIMEFORMAT="%d.%m.%y %T "' >> ...
1
vote
1answer
145 views

How to implement retry mechanism while executing the server url in the shell script?

I am working on a project in which I need to make a url call to one of my server from the bash shell script.. http://hostname.domain.com:8080/beat After hitting the above url, I will be getting the ...
1
vote
0answers
44 views

Disable commands for users [duplicate]

I have users that login automatically via ssh to a script I defined instead of a shell. The script basically launches a program which has a shell-escape in it which would allow the user to execute ...
0
votes
2answers
59 views

Different forms of executing a shell script

There are a few similar questions around that I've already seen, but I've come up with something different. I'm reading this http://www.tldp.org/LDP/abs/html/invoking.html and I got confused when I ...
0
votes
1answer
67 views

Bash code runs correctly when it is executed in terminal but does not work properly when executed using udev

I am trying to move various files present in a pendrive into their respective folders on PC. ie ,Music files into music folder,text files into Documents and so on.. I have written a script for that ...
1
vote
2answers
161 views

How to copy three files at once instead of one file at a time in bash shell scripting?

I am running my shell script on machineA which copies the files from machineB and machineC to machineA. If the file is not there in machineB, then it should be there in machineC for sure. So I will ...
0
votes
0answers
31 views

udev set kdbrate settings on linux with console users issue

I have a kbdrate setting as a udev rule for usb devices(keyboards and scanners that re repluggd in). kdbrate needs to be set by someone with /dev/port access which is the console user. The udev rule ...
0
votes
0answers
24 views

Convert rgba color value to a Terminal supported color

Randomly I will take the following example: rgba(122, 143, 186, 0.54) How can I convert this color to the closest Terminal supported color?