Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).

learn more… | top users | synonyms (2)

14
votes
4answers
602 views

What is the difference between '$ . foo' and '$ ./foo'? [duplicate]

t is a simple script What is different between two case below : $ . t and $ ./t
0
votes
1answer
25 views

Where to “install” node application and best way to launch

I'm pretty new to the Linux world, I have a Node application that I would like to distribute through an apt repository, this is what I do for now: Put the node binary inside the Node application ...
2
votes
0answers
35 views

Display cron job times in a human-friendly format

Is there a way to display or is there a tool that can parse a crontab expression and display it in a human-friendly way? 10 6 * * * sh /usr/local/crons/file_check.sh For example, for the above cron ...
1
vote
1answer
21 views

Why can't I see the output of scripts ran using ForceCommand in sshd_config?

I set up sshd_config with ForceCommand /path/myscript.sh for the user "tester": myscript.sh: #!/bin/sh echo test1 echo test2 | tee -a /home/tester/test.log The script is executed properly on login ...
-1
votes
1answer
45 views

I'm trying to create a script to send message “hello” to file name Hello in home directory

And display the contents of the file in the stdout using #!/bin/bash #!/bin/bash echo"hello" >> ~/Hello cat ~/Hello should I use tee ~/Hello to display contents of file Hello in stdout ?
2
votes
1answer
43 views

ssh and run script on remote host and answer expect answer automate

The ssh from server0 to (server1,server2,server3) (no password need to SSH (trust exists between all servers and private key exists on all servers)) but a remote script on server (server1,server2 ...
2
votes
2answers
47 views

Bash command: is it possible to pass an argument before a custom command (function) or it must be only after:

I am wondering if it is possible to pass an argument to a custom command before the command? Let say I have custom command ping and I would like to pass the IP address before command: instead ping ...
1
vote
1answer
41 views

I want to create a cron job that runs a command on a remote linux box using ssh but I want ssh to answer password [duplicate]

Thank you for the reply.This is not what I am after. The ssh from server 0 to (1,2,3) (no password) but a remote script on server (1,2 & 4 ) which starts a service/application needs a password for ...
0
votes
2answers
77 views

Shell script for ssh into a Unix/Linux server from MacOS X 10.10

I am attempting to ssh into a server by using a bash script from MacOSX. #!/bin/bash spawn ssh username@gatewayserver expect "password" send "Mypassword\r" interact spawn ssh ...
0
votes
1answer
37 views

Two errors when running ssh in a bash script [duplicate]

I try to run this script against a remote machine, to carry out login check, but have some problems executing it with no errors. I have the following error when I run the script: The Error: bash: -c: ...
0
votes
0answers
30 views

LFTP mirror includes - including other directories other than what i've included

My question: How can I make sure LFTP only includes files AND directories using --include or --include-glob, and not download a bunch of extra directories from the root of the remote that aren't in ...
1
vote
2answers
93 views

How do I wait for a file in the shell script?

I'm trying to write a shell script that will wait for a file to appear in the /tmp directory called sleep.txt and once it is found the program will cease, otherwise I want the program to be in a sleep ...
-1
votes
1answer
34 views

Shell script to get all the directory starting with a certain letters

I need to write some shell script to get all the directory that start with certain letters and save the result list in a txt file eg. -all uppercase directory -all directory that starts with "Ab" ...
2
votes
2answers
69 views

remove the low version number of file

I have these files: atk-2.8.0-ia64-11.31.depot gtk+2-2.24.25-ia64-11.31.depot lzo-2.09-ia64-11.31.depot bash-4.3.030-ia64-11.31.depot gtk+3-3.6.5-ia64-11.31.depot ...
0
votes
1answer
38 views

cronjob bash script called within another shell script not working

I have a shell script which calls a bash script within it. when I run this shell script manually it works fine however when I schedule this thru cronjob, the bash script is not doing the intended job. ...
0
votes
1answer
27 views

Loop for's result in a variable for sql query

I have this part of my script for i in `cat ${RELLIST}` do for mr in `cat ${i}/DBA/install.list` do grep -i "'dba_" ${i}/DBA/sql/${mr}/*.tab 2> /dev/null | sed 's/^.*://' #grep -i ...
2
votes
1answer
74 views

Set bash script output to the line that called bash script

I've looked for the greater part of two hours trying to see if I could find a way to redirect the output of a bash script to the line that called the bash script. The best example I can use to ...
0
votes
1answer
56 views

sleep command not doing what it is supposed to do? [closed]

Im making a bash script where I have to wait for a few seconds (max 10) then run a few commands. This is because when a program is started, it also starts a few useless subprocesses which I don't ...
11
votes
4answers
516 views

What is the meaning of IFS=$'\n' in bash scripting ?

at the beginning of a shell script program in the bash is the following line: IFS=$'\n' What is the meaning behind this collection of symbols ?
4
votes
3answers
77 views

How can I find and replace only if a match forms a whole word?

My script is: n="y" while [ "{n}" = "y" ] if [ $n == "n" ]; then break; fi echo "n is $n" do read -p "Enter the word to find = " word read -p "Enter word to replace = " replace ...
2
votes
2answers
55 views

suppress stderr messages in a bash script

Consider the following (slightly silly) script name 'test1.sh': #/bin/bash # sleep 10 & echo sleep pid = $! pkill sleep When I run it, I get not only the output of the echo, but bash's ...
0
votes
2answers
70 views

Convert input string to date in shell script

My shell script: #!/bin/bash echo "$1"; startd=$(date -d "$1" +"%Y%m%d"); echo "$startd"; My command: sudo ./test.sh "20151010" The output: 20151010 20150213 it printed todays date ...
0
votes
1answer
29 views

How to show a progress bar while tar a folder recursively?

In bash-script execution of taring not shown a progress bar, how to show a progress bar while taring a directory?
1
vote
3answers
60 views

How to include python script inside a bash script

I need to include below python script inside a bash script. If the bash script end success, I need to execute the below script. #!/usr/bin/python from smtplib import SMTP import datetime ...
2
votes
3answers
113 views

Processing input line by line (with empty lines) from shell

In a shell script, I need to parse the output of a command line-by-line. The output may include empty lines, and these are relevant. I am using ash, not bash, so cannot resort to process substitution. ...
0
votes
3answers
28 views

Error when trying to accept a directory path as a command line argument

I'm trying to accept a directory path as a command line argument in order to check recently changed files - not too sure if I'm doing it correctly: script=$scriptpath find . "$scriptpath" / -user ...
2
votes
1answer
32 views

Rotate image if width is greater than a value (i.e in pixels)

I was trying to rotate few hundred images which have 7000px height in 1000+ images how to rotate them from bash.
3
votes
4answers
279 views

Bash (Ubuntu) - Strings in while loops?

I am trying to create a while loop in bash that won't continue until the user enters the word "next". I can't seem to figure out how to use strings for the condition though. #Beginning of code ...
1
vote
3answers
217 views

Read longest line in file using while read loop?

I've been googling but I can't find any scripts that uses the while loop to read the lines. I'm stuck and I'm not sure on where to start Heres the question: Write a bash script longestline.sh that ...
1
vote
3answers
90 views

Compare two .csv files

I have two files: 'file1' has employee ID numbers. 'file2' has the complete database of the employees. Here is what they look like: file1 123123 222333 file2 111222 Jones Sally 111333 Johnson ...
0
votes
1answer
46 views

While loop stuck in infinite loop

I cannot figure out why this function gets stuck. What I am trying to do is create a folder from a predetermined start date up until the present month. Unfortunately it completes all the folder ...
2
votes
3answers
185 views

What is the purpose of a start up script? [closed]

So far I know the basic meaning of a script, it is a file containing shell-commands made executable by chmod +x file and able to be run by ./ file. My friend told me, he had to copy so called start ...
0
votes
1answer
34 views

nvm command not available in bash script

I am trying to build a script in in which nvm and eventually node will get installed. I have installed nvm with cURL. I see the modifications in the .profile or .bashrc file (both work) and when ...
0
votes
0answers
29 views

What do i have to consider to write a script that reacts on a keypress?

I know i can read within a script something into a variable, like this: variable = read But i have to press enter in order to submit the value into the variable. What do i have to know in order to ...
0
votes
0answers
18 views

checkbox to automated sql scripts run

I want to provide a menu in a shell script that offers a check list of SQL scripts to run. I actually need to execute the selected SQL scripts but it's about 20 of them and that make it hard to cover ...
1
vote
1answer
76 views

bash script problem when run from desktop launcher

I have a script which does the following: Connect via sshfs to a directory on a server Within that directory, there is an encrypted volume. Open it to the device mapper. Mount to a local directory ...
1
vote
0answers
24 views

Service script and shared libraries

I have the following simple script IPN in CentOS 6.5 in /etc/init.d/ #!/bin/sh # chkconfig: 2345 05 06 cd /root/IPNHost . /etc/rc.d/init.d/functions start() { echo -n $"Starting..." ...
0
votes
0answers
38 views

What is “Source Code For a Script”?

I am brand new to the Unix/Linux world and have a very rudimentary question for you. I am working on writing a shell script and towards the end we are told to "copy your source code for your script ...
1
vote
1answer
49 views

How can subtract 2 floats which have been extracted from 2 other files with BASH [duplicate]

I'm trying to get the difference between two numbers which I have taken from two files. I think my code will make sense: I've tried to make it work by two different methods, didn't work. What I get ...
1
vote
1answer
27 views

Non-block poll from two pipes?

Here is what I want to do.. mkfifo infrequentlog frequentlog sort -m infrequentlog frequentlog > mylog funcA > infrequentlog funcB > frequentlog So that when monitor tail, I can see the ...
0
votes
2answers
69 views

Not managing to make AND operator work in bash script

I'm trying to make a rather simple bash script where if the input is "on 1" it will execute an action and if it is "on 2" it will execute another action. I did a bit of googling about to find out how ...
2
votes
6answers
91 views

Scripting to split a single CSV row into multiple

I need a script that can take a CSV file with that has a column of semicolon-delimited attributes, and break it into multiple rows to normalize that multi-valued attribute? Here is the scenario: ...
1
vote
1answer
61 views

exec redirects in bash

I write a lot of non-interactive scripts where I would like all output to go to a log file and have nothing appear on-screen. To solve this, I've been using: #!/bin/bash exec &> logfile echo ...
1
vote
1answer
38 views

How to correctly deploy/install scripts?

I've developed several utility scripts that solve specific problems of my team's day-to-day work. Up to now, what I have done to deploy the script in my co-workers' laptops is as follows: Every ...
0
votes
2answers
27 views

Unix how to loop through directories, send output to another directory with base name of input file

I am an infrequent user of UNIX, I'm sure this will be fairly trivial for any regular user so I appologize for that. I have the following code: for file in /home/sub1/samples/aaa*/*_novoalign.bam ...
0
votes
2answers
43 views

How to use variables properly in this little script?

Here is a little script to retarget old-wrong symlinks that I want to make interactive. #!/bin/bash # retarget (broken) symbolink links interactively echo -n "Enter the source directory where ...
0
votes
2answers
50 views

Downloading images from csv file to a folder based on its id

I have a csv-file that looks like this (short example, there are actually about 20 images per id). ...
-1
votes
2answers
27 views

trying to reproduce “Unknown test operator” on HP-UX

HP-UX **** B.11.31 U ia64 ***** unlimited-user license LINE_COUNT=`wc -l ${LOG_DIR}/file_transaction.log` if [ ${LINE_COUNT:-"0"} -ge 10000 ] then mv ${LOG_DIR}/file_transaction.log ...
1
vote
1answer
40 views

How to use bash shell for gnuplot to show Greek letter?

I want to write a bash shell for gnuplot to produce figures automatically. But my figure includes Greek letters inside. I have known their ASCII number, how can I show them correctly in figures after ...
2
votes
2answers
46 views

Find and rm command not obeying exclude list occassionally

I am running a find and rm -rf directory list modified earlier than 7 days with an exclusion list of directories which should not be deleted at any case. This is the script excerpt find ...