1
vote
3answers
73 views

How to get a response from any URL?

I have been asked to write a shell script To check if a URL is UP/Working or not for my Project. I tried to find some hints over the internet, but whatever I got is about checking whether the URL ...
1
vote
1answer
36 views

Compare file size of multiple files in an array [closed]

Scenario: Ftp site has 100s of files. Once a day, all the .gz files are copied to an AWS site then renamed. Only the date is kept in the file name. Some of the files corrupted during copy. A txt ...
1
vote
2answers
188 views

How to iterate through multiple file extension without caring about case sensitivity?

I've seen various topics on how to iterate through multiple file extensions but in most case, the list is defined. example: for file in ${arg}/**/*.{txt,h,py} do .... done As can be seen, ...
5
votes
3answers
196 views

How to iterate through a list of files with spaces that is sorted (case insensitive)?

I am doing this in OSX which uses bash but obviously, not all bash conventions are used so hopefully your suggestion is available to me :) I have the following files fun bar1.txt Foo bar2.tXT ...
2
votes
1answer
40 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 ...
6
votes
2answers
81 views

Passing arguments from a file to a bash script

I' ve got this situation: ./ ./myscript.sh ./arguments.txt ./test.sh Inside myscript.sh, i have to run the file test.sh, passing to it the arguments contained inside arguments.txt. myscript.sh is: ...
0
votes
1answer
31 views

Reusing user input in a script

I have the following script which works: #!/bin/bash xfreerdp /cert-ignore /f /v:farm.company.com /d:company.com /g:rds.company.com /u:$(zenity --entry --title="Username" --text="Username") ...
0
votes
2answers
106 views

If UID=1000 continues, else exit

I am wondering how to implement the following in a bash script. if UID=1000, continue else exit confirm choice (y/n)
0
votes
1answer
46 views

Converting windows date logic into Unix [closed]

I had coded the below logic in Windows batch scripting and I need to replicate the same in Unix. # Calculating Yesterday's Date for /F "tokens=1-4 delims=/- " %%a in ('date/T') do set DY=%%c for ...
1
vote
2answers
72 views

SCP Automation in production environment [duplicate]

I want to implement the use of scp command in a production environment. I don't want to provide my password in the automation script. Is there any way? I need step by step solution.
3
votes
1answer
54 views

Launch RDP silently?

I currently use the following command to launch an RDP session which works fine: rds@rds:~/Downloads/FreeRDP$ xfreerdp /v:farm.company.com /d:company.com /g:rds.company.com /f /u:username /p: At ...
1
vote
1answer
79 views

Change a value in a config file, or add the setting if it doesn't exist?

When modifying config files from the command line, I often want to find the setting in the config file and modify that line if that setting exists. If that setting doesn't exist, I want to add it to ...
1
vote
1answer
25 views

How do I obtain the kill signal / message / reason within a script?

I am using the following trap: trap OnExit EXIT And in my OnExit function I would like to capture all the info I can on what happened so I can write it to a log file. Id like to know who, why, how, ...
2
votes
1answer
521 views

What is wrong with this code?

I have a script that goes like this: while : do Start_Time=$(date +"%s") MAIN PROGRAM GOES HERE (CROPPED TO SHORTEN THINGS) Run_Time=$(( $(date +"%s") - $Start_Time )) if [[ ...
2
votes
4answers
249 views

Inserting a line in a file only if this line isn't yet part the file

Total newbie to shell scripting, I am searching to create a script to automatically apply some custom configuration to text based configuration files. In the present case, I am searching to add 2 ...
-1
votes
1answer
35 views

How can I search for a user account in various sudo related config files?

I'm a scripting newbie...and I would like to search multiple servers for user ss7459 in the following files /etc/sudoers, /etc/sudoers.d/itse, /etc/sudoers.d/dbas and /etc/group. NOTE: The numbers ...
3
votes
2answers
114 views

Checking the status of custom services with a script

I have a handful of shell scripts that start WebLogic managed servers. I need to design a master script that does the following: Executes the shell script for a component\managed server Checks to ...
0
votes
0answers
29 views

shell script for executing mux verilog code

I have a verilog file mux.v and testbench muxTB.v. used ifdef caeses for behavioural model ifdef struct for structural model I have executed these files using the commands iverilog mux.v muxTB.v -D ...
3
votes
5answers
128 views

Look if a folder has some files of certain extention

Lets say I have a file structure: $ cd /home/Desktop $ ls -d */ Abc/ Qwe/ Zxc/ Rty/ $ Now I want to iterate through every directory and look if they have any .pdf files. Could some one please ...
1
vote
1answer
154 views

Shell script and crontab to capture file size, name and date in a CSV file and then send via email?

I have a number of zip files in a certain folder. I want to capture file name and the size of the files in a CSV format in day wise and put it in crontab so I can report on a daily basis, and then ...
0
votes
2answers
76 views

Simple Script to setenv tcsh or export bash

I am having problems with simple scripting, my Box is CentOS so bash is the default shell, now I wanted to send a line via setenv (tcsh) and would like to make a script that will ask me to input a ...
2
votes
3answers
112 views

grep on a Java Method

Lets say I have a java class called DirectAction some of the methods in the class have the word "action" or "Action" What is the grep command to get the names of all the methods who have "Action" or ...
0
votes
2answers
73 views

shell or python script to transpose rows to columns [duplicate]

I have a big file with numbers like: 1 2 3 4 5 6 7 8 9 9 9 9 I want to tranpose it into 1 5 9 2 6 9 3 7 9 4 8 9 I have search on google for solutions, but those solutions simply don't ...
1
vote
1answer
42 views

Delete a matching line in a file doesn't work

So, I have this piece of a code: while read line do if [ $line = $maddr ] ; then sed -i '/${maddr}/d' mailinglist found=true ...
4
votes
1answer
40 views

Memory consumption of a script

Is there way to check the memory (physical & virtual) consumption of a script, of course in the moment of its execution. Calculating the used memory minus the used memory before and after the ...
7
votes
2answers
450 views

Check bash/shell script dependencies

Is there a method/command to check for the dependencies of a bash script? In other words, a response to this question : Which libraries should a user install to run the script? I can do this ...
1
vote
3answers
570 views

Bash script for automatic tar backup of chosen files and directories

Within a given directory in linux environment, I need to pick all files modified after a certain date (let's say 7 days) as well as all directories (only in root directory, hence non recursively) ...
0
votes
2answers
40 views

Use xdotool in a telnet session

I have to simulate key presses in a telnet session, and everything has to be invoked by a shell script. #!/bin/sh telnet 192.168.1.14 50000 xdotool type "404" However, once the telnet session ...
1
vote
1answer
268 views

Create a iptables rule if the rule does not all ready exist

Hi I've created a script to setup Nagios on my remote servers. My Script checks iptables to see if a firewall rule all ready exists and then is supposed to add the rule if it's not all ready there. ...
1
vote
1answer
139 views

What does “if [ -e $name ]” mean? Where $name is a path to a directory

In the if [ -e $name ], what condition check is -e? $name is a variable of a path to a directory.
2
votes
2answers
48 views

How to format textutil -excludedelements

I use Geektool on the Mac to display various information on my desktop. One feature of Geektoool is the ability to use shell mode to launch custom scripts or commands. I am not versed in any type of ...
2
votes
1answer
49 views

I'm trying to count and print song file names using awk as following

RANK NAME BAND YEAR GENERE DOMESTIC/INTERNATIONAL 206:Reach Out, I'll Be There:The Four Tops:1978:Pop:3/2 207:Bye Bye Love:The Everly Brothers:1950:Classic:3/2 ...
-2
votes
2answers
55 views

How to delete a directory from terminal?

I'm trying to delete a directory after a series of events take place. That being said, I need to be able to place this in a file to execute once said events take place.
0
votes
2answers
114 views

Scripting Language Evolution [closed]

I have an assignment due Monday and I need some help because I have no knowledge on the subject and can't even understand what to search exactly. I am not waiting for an essay or something just some ...
3
votes
2answers
56 views

Bash script : help file inside the script or in a different file?

I'm writing a script that has the vocation to be a fully featured program at the end. As far as I know, BASH is enough for his purpose (manage PPA's, kinda like Y-PPA). I would like to know how to ...
3
votes
5answers
217 views

How can I force a script to use more resources?

I'm running a very time-consuming script which takes many hours to end. Watching top I see that it's only taking 5% of the CPU at best, usually around 3%. Is there any way to force the script to use ...
1
vote
2answers
151 views

Creating a shell script that parses and redirects number into next command?

I am trying to create a script that kills an Xorg process. Here is an example of me running the commands in a terminal: First, I find the process id of the Xorg program (in this case, 2494): . ...
4
votes
4answers
5k views

Check for Process if Same is Running

Is there a script or a way in linux that when I try to execute a shell script/process, if the same is running, it will prompt that same is running and will exit otherwise it will continue.
-2
votes
2answers
642 views

how to execute a python program in a shell script

I have a python program in that I wrote some python code (disk.py). I executed this program using the command python disk.py in a terminal, it worked. Now I want to execute it using a shell script.
1
vote
3answers
235 views

What does “FILENAME=$(echo $INFILE | grep -oE ”[^/]+$“) ” mean?

FILENAME=$(echo /root/Source/code/script.sh | grep -oE "[^/]+$") I know that it would give me the file name from the file path here as script.sh. But can some one please explain me this?
4
votes
3answers
165 views

shell script problem with using the operators

I am comparing two strings using the levenshtein distance algorithm. I got the PHP implementation of the algorithm from here. I am calling this php implementation from my shell script as below. ...
7
votes
1answer
230 views

Parallel execution of bash script

I have a table URL_Experiment in my database (mySQL database). I have 2 million URL links in this table. For each URL, I am checking if some particular text is present in the URL and updating the ...
1
vote
1answer
78 views

print all values of a file after removing some characters using grep

I have a file in which the values are stored as below. Assistant Professor at SASTRA University St John's memorial college Paul George Univeristy Department Chair at University of Texas I am ...
2
votes
3answers
545 views

Extracting characters after a particular text

I am extracting a page from website using cURL command. curl "www.google.com" -s | w3m -dump -T text/html > foo.txt The w3m command outputs the HTML page in a much more simpler format so that ...
2
votes
1answer
247 views

shell script construct array for file elements

I have a file named input_file which contains some lines. I need to remove certain characters in the line and store them in an array. So to remove the characters, I use the sed command and storing in ...
1
vote
2answers
64 views

Make Trickle get the correct $PATH

Trickle is a bandwidth limiting program. I have the following script for trickle. #!/bin/bash echo $PATH trickle -s -t 3 -u 200 -d 200 "$@" I have a script in ~/bin/ that want to run the script ...
2
votes
1answer
2k views

curl and grep commands output into a new variable

I am extracting information from a website. I designed the code in VBA and found that it is taking too long to execute. So, I have decided to rewrite the code in Unix script. I am extracting a page ...
-3
votes
1answer
72 views

why does the dollar sign cause this command to be executed?

test_script.sh: #!/bin/sh D1="$(dirname $0)" echo $D1 D0="(dirname $0)" echo $D0 What I type on the command line: $ ./test_script.sh Output: . (dirname ./test_script.sh) What significance ...
0
votes
1answer
222 views

Can I use an if statement to detect if bash and dash are being run interactively? [duplicate]

After looking around for a while I've found several good pages describing how to check and see if a bash script is running interactively and there seem to be several methods, but one of them that I ...
-2
votes
1answer
101 views

automatic capturing top output by cronjob CENTOS 6.5 x86_64

I have this command: top -n 14400 -a -b -d 1 > /toplogfile.txt I want to make a script which is run by cron every day to capture top output, and if it is possible gzip the output file after the ...