A shell script is a script written for the shell, or command line interpreter, of an operating system.

learn more… | top users | synonyms (1)

0
votes
1answer
20 views

How to pipe binary stdout to a compressed tls connection?

Not so long ago, I could use : cat somefile.txt | openssl s_client -connect server:port -quiet -comp However, this command doesn’t work, even with-ign_eof: $ cat somefile.bmp | openssl s_client ...
1
vote
1answer
17 views

To create shell script

I want to create a script to check size of all the files present under particular folder, and if size of any file present under a folder cross 500mb it would trigger a mail to me specifying the file ...
2
votes
1answer
2k views

How can I tell if the lock screen is active from the command line on OS X?

I have a cron script that I want to run regularly if I am logged into my Mac. I don't want it to run if the Lock Screen is up. Is there a way to check from the command line / Terminal if the Lock ...
1
vote
1answer
16 views

How to pass array to bash shell script?

How do I pass an array as a variable from a first bash shell script to a second script. first.sh #!/bin/bash AR=('foo' 'bar' 'baz' 'bat') sh second.sh "$AR" # foo sh second.sh "${AR[@]}" # foo ...
1
vote
1answer
14 views

Accessing array index variable from bash shell script loop

I want to access the array index variable while looping thru an array in my bash shell script. myscript.sh #!/bin/bash AR=('foo' 'bar' 'baz' 'bat') for i in ${AR[*]}; do echo $i done The result ...
3
votes
2answers
807 views

How can uptime be used to trigger an action?

I want to write shell or perl code which would give me notification after x days. Basically on SUSE Linux server, there is reboot required after 208 days, else the system would freeze. This is known ...
0
votes
1answer
43 views

searching the string with the time in log file using shell script by passing variables

I want to search a string and subtract the time that is found from the current time. When used, the script should show the lines from that time or from the very next log time frame. I'm able to ...
1
vote
2answers
1k views

How to remove blank lines in .txt files

I want to change a text file's format, removing all blank lines. How can I do that? (2) 5. The function of the condenser is to: a) vapourise the liquid refrigerant b) change ...
1
vote
2answers
93 views

How can I elevate my cmd prompt using the the cmd line

I follow this script "runas /profile /user:administrator\administrator cmd"and when it prompts me for my password it always says that it is incorrect even though i am spelling it correctly. help ...
0
votes
1answer
17 views

How to run a shell script from an AppleScript?

I am using a Mac running OSX Yosemite v.10.10.5. When I try to run my shell script from my AppleScript, I get the following error message: Error message at AppleScript Script Editor error "sh: ...
0
votes
0answers
26 views

Shell script - Unable to copy file from one older to another

I need to copy the files from one folder to another, here source and destination information are in the text file. File content: resconfig.txt cp -f /var/lib/jenkins/jobs/Android\ Gradle\ test\ ...
0
votes
1answer
19 views

Shell Save the array element values in the variables

I need to copy the files from one folder to another, here source and destination information are in the text file. File content: res.txt /var/lib/jenkins/jobs/Android\ Gradle\ test\ ...
0
votes
1answer
22 views

Bash script to find content of file in a directory and add value

I have a directory with a huge number of files. I want to write a bash script to - Enter that directory Find out which of them are Perl scripts (but none of them have a .pl extension) Add a line at ...
-1
votes
0answers
13 views

Search content of odf (odt|ots|odp) documents from command line

I want to search the content of some odf document (Libre Office document) from command line. I want something like: odfgrep <search-pattern> <file-name> I found something of interest ...
0
votes
2answers
45 views

Fetch required column from a file with \001 delimiter

I am storing output of pig file in a directory Which contains lines with multiple columns separated by delimiter \\u0001. Now in shell script I want to fetch 7th column field from the output. I ...
1
vote
1answer
521 views

script for auto adding routing table entries

There are a lot of remote agents that use Mountain Lion. We want only the directories on our intranet to be go through the VPN tunnel and all other traffic to go direct out. So to do this I had to add ...
0
votes
2answers
21 views

Evaluate each environment variable and set it back in ubuntu

I'm trying to write a shell script which reads all the environment variables, evaluate them for included env. variable with in them and re-export after evaluvation. Example - I've an environment ...
0
votes
1answer
17 views

How to programatically modify systemd unit files?

I'd like to edit a systemd's unit file from a shell script. I want to change the unit's only ExecStart line. Using systemctl edit looks smart to me, but the command needs an editor set as ...
1
vote
0answers
13 views

Detecting new USB devices with bash?

I'm writing a bash script that needs to detect when a usb storage device is inserted and assign it to a variable that would otherwise, typically look something like: usb=/dev/sdb. I have a few ...
5
votes
1answer
4k views

Can I “export” an alias to the SHELL that invoked a script?

I'm trying to write a utility script that defines certain aliases. My SHELL is tcsh (can't change that). I tried the following #!/bin/tcsh alias log 'less ~/logs/log.`date '+%Y%m%d'`'' Then I ...
22
votes
9answers
14k views

Log rotation of stdout?

I have a Linux program which can write information to stdout and stderr. I have a shell script which redirects that output to a file in /var/log. (Via >> and 2>&1.) Is there a way to ...
6
votes
3answers
7k views

Recursive unrar of several folders

I have several RAR archives spread around multiple directories but all under a particular root folder on my Debian based NAS. Could someone help me write a simple script that would recursively go into ...
0
votes
3answers
53 views

Shell script Copy file from one directory to another not working

Hi I am trying to automate the android build system through jenkins. Here I am trying to copy the image file from one directory to another directory but always getting " No such file or directory" ...
0
votes
0answers
30 views

PowerShell Script is not digitally signed

I am trying to call a Powershell script from another Powershell script. When I try to execute the script, I receive to following error message: After researching the error on Google, I entered the ...
14
votes
3answers
9k views

How to update bash on Mac OS X Yosemite

Just trying to learn bash scripting a little. My old bash version: Bash version 3.2.53(1)-release... I've updated my bash on mac os x yosemite with homebrew: brew update brew install bash Then ...
0
votes
1answer
39 views

Shell Script excuted fail in Linux at command

When I run a Linux "at" command,I find the user's shell script executed fail, for example,I write the following code in my script #!/bin/csh #or #!/bin/bash echo "Now will excute a shell script" ...
0
votes
1answer
40 views

Shutdown a linux computer depending on the battery level

Is there a way to shutdown a linux-based computer when the battery charge drops below a certain level? I have searched through the shutdown and poweroff manuals but found nothing relevant.
0
votes
1answer
22 views

How to run script in same session without exec?

I have below script to set me in my project:- #! /bin/zsh source ~/.zshrc crld #alias for Project base cd Kenneth_Love/survivalguide workon kenneth_tutorial This script works but doesn't drop me ...
0
votes
2answers
91 views

How to Sum Date (in minutes) Shell

I need some help here, I'm not a expert with shell scripting but I am trying to do a script where I need to take the Epoch number followed by the date, but for with the all hours of the day with a ...
-1
votes
0answers
11 views

Auto Submitting SECOND form in ELINKS

I am automating something in ELINKS using shell scripting. I am successful in auto submitting the first form in ELINKS using the -auto -submit flag, when launching ELINKS. Now I want to submit ...
-1
votes
0answers
19 views

AppleScript for Preps 7

I want to write a script to automatically process files with Kodak Preps 7. But can't find the list of supported commands AppleScript for Preps (maybe sdef file). Can anybody tell where can I find ...
0
votes
2answers
56 views

How to POST file contents using cURL?

I want to do an HTTP POST of the contents (as a string) of a local file located at path/to/my-file.txt to a URL endpoint at http://example.com/. For example, I might want to do the following: ...
-2
votes
3answers
280 views

How can I write a bash function that checks if an integer is even or not?

How can I write a shell predicate function event that takes an integer argument and tests if it's even or not?
0
votes
2answers
25 views

new column to a tab delimited file, with as predefined value

How can I add a new column to a tab delimited file, at the end of the file, containing the same values for each row. For example: infile.txt Name Age Address Sex X 12 adrs1 M Y 15 adrs2 ...
0
votes
0answers
22 views

Triplicate entries of a column

I have a data column with over 2000 entries... MV1 BNV CMG IKN ... ... I want to triplicate each entry in the column format. Result should be; MV1 MV1 MV1 ...
2
votes
1answer
48 views

Merge only new entries from one xml file to another

I have 2 xml files. The 2nd file has some new entries including same entries as that of the 1st file. Examples of the 2 files are given below. File 1 <SERVERNAME_ONE> ...
0
votes
1answer
49 views

arithmetic operation on a nested column in a tab delimited file

I have a tab-delimited text file containing Column1...Columnn columns and R1 to Rn rows. Within some of the columns, there are multiple nested fields with an identifier and then separated by semicolon ...
0
votes
1answer
48 views

Shell script, AppleScript Mac OS X

I’m trying to copy embedded metadata from image files and write to a .txt file, as well as generate MD5 and SHA1 checksums for the same images to be added to the same .txt file. I can run this ...
0
votes
2answers
56 views

simple arithmetic operations on a tab-delimited text file in shell script

I have a tab-delimited text file containing C1...Cn columns and R1 to Rn rows. Column 10 (C10) has a field 'X'=four comma separated integer values (X=a,b,c,d). I would like do a small arithmetic ...
0
votes
1answer
312 views

Awk script to run a command based on condition using 'if'

I have a piece of code here that basically takes a file called 'srcip' (which is just a list of IP addresses) and compares it to my '~/db' file which is just a tab delimited IP HOSTNAME database of ...
0
votes
1answer
30 views

how to write a shell script to take password automattically after the execution of command

#!/bin/bash cd /var/SUNWdsee/ds6/bin ./dsconf show-repl-agmt-status -e suffix Hostname:389 Above is my script. After the execution of the last line it will prompt for password in screen. I need to ...
0
votes
1answer
39 views

dos2unix command is corrupting the file with unicode characters downloaded via binary mode

i downloaded an xml file having unicode characters from ftp in binary transfer mode. In order to remove the line ending special characters i used the command dos2unix. But this is making the file ...
0
votes
0answers
11 views

cronjob not finding commands [duplicate]

I am running (and also new to) OS X El Capitan. I have a user cronjob that is using some basic commands that I got via brew. wget and s3cmd I have the cronjob executing a shel script in my user bin, ...
1
vote
0answers
40 views

Colon(:) operator in Unix shell

As far as colon is concerned i understand that is is used in certain situations as a null and as a parameter of expansion for substring, but can someone explain me this: do_qc: $(STAGE1_OUT_FILES) ...
0
votes
0answers
22 views

Bash to dos conversion trouble windows path cygwin

I am having a problem with this script that is run through cygwin using a bash script. I need to run this script using a direct network path which is shown in the second snippet of code. #!/bin/sh -p ...
0
votes
2answers
341 views

OS X shell script to connect to a known wifi AP without explicitly using a password

I'm trying to write a shell script that begins by connecting to a specific SSID (one that I've connected to before, a preferred network). The only way I can seem to do this via command-line is: ...
1
vote
1answer
20 views

pass du (disk usage) result to a numeric variable

In a shell script, I'm looking for a way to pass the du (disk usage) result to a numeric variable, so that I cantie the execution of a shell script to the size of a specific folder. I've tried ...
2
votes
1answer
57 views

tcsh: how can we display the body of a foreach loop in history

I see that history doesn't display the body of loops. Is there a way to show them? san: cd /tmp/test san: touch abc san: touch def san: ls abc def san: foreach file ( `ls` ) foreach? echo "File is ...
0
votes
0answers
11 views

Automate creation of content and sending mails from template and list of required variables

I have a list of so many users with their email ids Names Mohit Shrivastava Axyee Jackson ... Corresponding email ids mohitemail@domain.com axyee@domain.com ... I want to send all of them ...
0
votes
1answer
42 views

How to find files modified in last 24 hr but do not find from hidden directories and sum them

I have following command to find files modified in last 24 hr and sum all of them. #!/bin/bash find /mnt/naspath -mtime 0 -print0 | du --files0-from=- -hc | tail -n1 >> /tmp/size.log exit 0 ...