0
votes
0answers
54 views

Mirrored Linux Commands [closed]

I've encountered two incidents where commands (or logic flow) is given forward and backwards In bash scripts: if ... fi (use to closed an if-statement) and in GNU/Linux command line: cat; tac (cat ...
1
vote
0answers
15 views

Mirrored Linux Commands [duplicate]

I've encountered two incidents where commands (or logic flow) is given forward and backwards In bash scripts: if ... fi (use to closed an if-statement) and in GNU/Linux command line: cat; tac (cat ...
3
votes
1answer
62 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 ...
1
vote
1answer
52 views

How to run java service as a non-root user on CentOs 6

I have a script that starts a Java application as a service on CentOS 6: #!/bin/sh # chkconfig: - 80 20 SERVICE_NAME=cn4server PATH_TO_JAR=/usr/local/share/myserver/cn4server.jar ...
2
votes
1answer
68 views

Accumulate Filename in a Log file using shell script

I have files with their names as ABC_-_123321.20140505_-_161500.CSV ABC_-_654145.20140506_-_135020.CSV String_-_SerialID.Date_-_Time.CSV StartDate, StartTime, EndDate and EndTime are given as ...
1
vote
3answers
169 views

How to read the file line by line and to print the previous line where the file contains a single token

For example my file is like: 59 6 18 2014 169 7 14 2 7671912 7849744 201 4 60 6 19 2014 170 5 49 2 7671912 7849744 201 5 61 6 20 2014 171 6 8 2 7671912 7849744 201 6 62 6 23 2014 174 5 3 2 7671912 ...
3
votes
4answers
155 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 ...
0
votes
0answers
40 views

Specific Jar file doesn't run on startup

I want to run a jar at startup, so I asked a question here. I was given a few suggestions, so I started from trying to create a script file and desktop file. I created a script file and desktop file ...
0
votes
1answer
53 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
2answers
103 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
991 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 ...
1
vote
2answers
113 views

Run jar on startup in all *nix based systems

I have a jar file which I need to run at startup in all distros of Linux. My previous question here, gave me an idea a rough idea on X-servers. Since I wasn't able to perform startup, I moved on to ...
1
vote
4answers
107 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
165 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 ...
3
votes
2answers
106 views

Start zsh with a custom zshrc

I want to be able to start zsh with a custom rc file similar to the command: bash --rc-file /path/to/file If this is not possible, then is it possible to start zsh, run source /path/to/file, then ...
2
votes
1answer
47 views

Capture symbolic link into Unix/Linux variables

Say I have a folder with a series of symbolic links: ussdv103:en195d; default$ pwd /oradba/app/oracle/admin/database1 ussdv103:en195d; default$ ls -ltr exp -> ...
0
votes
1answer
33 views

how can I replace a record in my DB (mySql) by new record?

I have created a shell script to connect to a DB and INSERT IPs and MACs from dhcpd.log file: #/!bin/bash dhcpLogFile="/var/log/dhcpd.log" NumberOfLines=$(awk '/DHCPACK/ { print $8} ' $dhcpLogFile | ...
1
vote
2answers
47 views

Is it secure to connect remotly to Mysql using shell?

I have created a shell script to connect to a DB and do some queries: #/!bin/bash ... ... mysql -h remote -u root --password='pw' MatchingDB some SQL queries My question is : Is this connection ...
0
votes
1answer
33 views

how to ignore a MySql error and go on to the next query?

I have created a shell script to connect to a DateBase and INSERT IPs and MACs from dhcpd.log file by connecting to the DB only once: #/!bin/bash dhcpLogFile="/var/log/dhcpd.log" NumberOfLines=$(awk ...
2
votes
1answer
62 views

how to Connect to Mysql only once?

I have created a shell script to connect to a DB and INSERT IPs and MACs from dhcpd.log file the scripts worked properly: #/!bin/bash #Defining Variables dhcpLogFile="/var/log/dhcpd.log" #Begin Code ...
2
votes
3answers
359 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
2answers
121 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 ...
1
vote
2answers
102 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 ...
1
vote
1answer
39 views

Tile logfile into pieces and search for errors

I want to tile a logfile into pieces and then search in this pieces for errors. If there is an error, I want to put the relevant logfile-piece into another file. Little example: Logfile looks like ...
-1
votes
1answer
52 views

Unix Awk group by

Can anyone shed me light how to group by based on the username and sum the values divide it by number of rows of that specific username. for example below. root 25 oracle 25 batch 30 griduser 20 ...
2
votes
3answers
88 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 ...
1
vote
1answer
110 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 ...
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 ...
1
vote
2answers
140 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 ...
1
vote
1answer
899 views

Easiest way to mount Google Cloud Storage in CentOS

we use centos for some hosting projects, but nut very expertise with systems. We pretend to use a main CentOS box to mount an "unlimited" Google Cloud Drive and then share it via NFS to the rest of ...
0
votes
0answers
21 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?
1
vote
1answer
76 views

How to check for a folder inside a particular folder in shell script?

I am working on a shell script and python script as well. Python script is passing certain parameters to my shell script and then I am using those parameters in my shell script. Below is my shell ...
6
votes
4answers
1k views

How to extract logs between two time stamps

I want to extract all logs between two timestamps. Some lines may not have the timestamp, but I want those lines also. In short, I want every line that falls under two time stamps. My log structure ...
2
votes
2answers
115 views

Linux Shell fundamentals: How can I check the file descriptors status, (where are redirected to) right now without lsof?

I am learning about file descriptors for the case of Linux, and I was wondering if there is any command showing a complete list that allows me to know where is each one redirected to in this moment. ...
2
votes
1answer
64 views

Accidentally typed crontab with just the dash

What happens when I type just "crontab -"? The "e" didn't take before I hit Enter. It just moved the cursor to the next line and I had to Ctrl+C to exit, but I'm not sure what it did exactly. I'm on ...
1
vote
1answer
85 views

how to check if mysql table is used or an application accesses the table in shell script?

A shell script is doing dump for a mysql table, but before dumping the table I want to check if this table is used by any other application. If so, I want to wait and enter in a loop until the ...
2
votes
2answers
54 views

git diff - listen for key press

I want to run the following commands: git diff git commit git commit will open the default editor to edit the commit message. But if the difference if not too long it will close immediately. How ...
14
votes
4answers
1k views

How Does Linux deal with shell scripts?

For this question, let's consider a bash shell script, though this question must be applicable to all types of shell script. When someone executes a shell script, does Linux load all the script at ...
5
votes
4answers
461 views

Run a command when system is idle and when is active again

I want to run a command when the user becomes inactive (the system is idle). For example: echo "You started to be inactive." Also, when the user becomes active again (the system is not idle ...
1
vote
1answer
246 views

Not able to copy multiple files using rsync 3.0.9 version?

I am trying to copy two files using rsync from a machineB but somehow it always copies only one file but not the second file - Here is the syntax I am using - rsync -avz ...
2
votes
3answers
310 views

How to use rsync or scp to efficiently copy the files from machineB and machineC to machineA?

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 ...
1
vote
2answers
103 views

How to find out all the files in other machines using bash shell script?

I am trying to find out which files are in machineB and which files are in machineC. And I need to run my shell script on machineA to figure out which files are in machineB and which files are in ...
2
votes
1answer
154 views

How to detect global key presses

I have an Asus laptop that has a special key that can be configured to launch any software (at least on Windows). The general question is: how can I detect any key press (globally)? Then, how ...
1
vote
1answer
907 views

How to exit out of the shell script successfully so that python subprocess think it is successfull exit? [closed]

Below is my shell script which simply execute a url like this http://example.com:8080/beat and parse the response and verify certain conditions on it. If that condition is met, then exit successfully ...
3
votes
6answers
295 views

When does a shell get executed during the linux startup process

I do not understand when does a shell, lets say bash, get executed, which program runs bash initially first.
-1
votes
1answer
56 views

Remove directory without `rm -r`

How to remove non-empty directory without using rm -r or find -delete ? I think it is related to unlink, perl or inode
4
votes
2answers
402 views

Where is a shell script run from?

I have a shell script in /usr/bin. Let's call it hello. It contains this: echo "I am located in $PWD" echo "I am called from this directory: ???" Running hello from /home/Documents I expect the ...
3
votes
1answer
336 views

adduser: Specify only one name in this mode

I'm trying to add a user with this command on my debian server: #!/bin/bash APPUSER="test1" APPGROUP="test2" # User adduser -c 'uwsgi user' --group $APPGROUP --system --no-create-home ...
2
votes
3answers
154 views

Disable login for useradd [duplicate]

I tried to disable login for a user account but got this error in debain: useradd: unrecognized option '--disabled-login' What is the equivalent of this command for useradd? Do I have to pick ...
0
votes
3answers
78 views

remove new lines

My input is a csv file like this: 10,"Special Projects,bangaram",0,,0 10,"Statutory/ Internal Audit , MO reporting (incl Excel Spreadsheet uploadation) ", bangaram,0,,0 10,"Complience with ...