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

learn more… | top users | synonyms (2)

0
votes
0answers
23 views

how to insert seperate lines ( elemnts ) in parameter [on hold]

I have the following csv file more file.csv 1,yes,yes,customer1 2,no,yes,customer5 3,yes,yes,customer11 4,no,no,customer14 5,yes,no,customer15 6,yes,yes,customer21 7,no,yes,customer34 ...
1
vote
2answers
48 views

How to grab output from command in shell script

I'm trying to write a shell script in RHEL which will execute grub-md5-crypt and the user will type their password. Now the problem is how can I grab the encrypted md5 hash displayed to the user in ...
0
votes
0answers
14 views

File not found (cygwin on Windows)

Windows 7 TeX Live 2014 I am trying to install Minion Pro and Myriad Pro for the use with pdflatex. When I try to run the script in cygwin via name@pc-name /cygdrive/d/LaTeX/FontPro-master-Build01 ...
1
vote
0answers
19 views

Solaris 10 : command to copy text to the clipboard. (command line)

I'm searching a command to copy text to the clipboard. xclip and xsel are commands which are available on several Linux and Unix OS-es, but is unfortenuately not available on solaris 10. ...
2
votes
2answers
37 views

How to make my bash script be able to create an log file for a clamscan running in cron?

I've created an custom clamscan(clamav) in bash and when I run it in my shell everyhing is fine, but if I run it in a cron, it can't create the log file. This are the errors: ...
-3
votes
1answer
41 views

Shell Script to copy the file to another folder

I am new to Linux, I have to write .sh file which will be called from .Net Application. Script.sh has to move the file from rootdirectory to a specified folder. I am expecting to pass SourceFilePath ...
1
vote
2answers
56 views

Shell script throws a not found error when run from a sh file. But if entered manually the commands work

Im trying to use the following script to generate a sitemap for my website. When I run it as sh thsitemap.sh I get an error like this and creates an empty sitemap.xml file : thsitemap.sh: 22: ...
5
votes
4answers
258 views

How to rename to fixed length

I have files named as 0-n.jpg for n from 1 to 500, for example. The problem is that some guy using Windows didn't use leading zeros so when I do ls I obtain 0-100.jpg 0-101.jpg ... 0-10.jpg ... ...
0
votes
1answer
16 views

Bash to Fish Conversion: Display custom message when CD'ing into a specific directory

Basically, I'd like to create a file .cd-reminder with an announcement/message inside a specific directory. It will be displayed every time someone 'cd' into that specific directory. There is a shell ...
1
vote
1answer
69 views

Use saved input for scripts

I have a few scripts that I constantly enter in input as below: [support@ccfcore-3 exporttool]$ ./sendExamToRepo.sh Enter the Study Instance UID: 2.25.98472613238667427310842065102689842379 The ...
0
votes
1answer
32 views

How to set the environmental variable for my scripts same as the users shell? [on hold]

I want to know how to set the environmental variable for my scripts that I have written such that they are the same as the user. This way I can save time in giving an absolute path of the command.
0
votes
1answer
24 views

Init script to run a script as specific user

/apps/data/service/bin/startup.sh This is the script i want to be executed during RHEL booting. I want it to be run in runlevel 3 only. And i want this script to be started as specific user, ...
1
vote
0answers
23 views

Setting XDG_DATA_HOME and XDG_CONFIG_HOME on compile/per program

The goal is to have a -dev version and a stable repository-based version installed at the same time, but with different data and config directories so that the dev version is not operating on(and ...
2
votes
1answer
35 views

get the name of new directory that created out of tar command

How can I get the name of new directories that were crated out of tar -xvf command? For ex. When I run the command tar -xvf jdk-7u17-linux-x64.tar.gz the contents of this tar extracted in a new ...
1
vote
1answer
40 views

How to send a mail when someone remote connects to my server

I would like my server to send a mail to me when someone connects remotely over ssh to my server. who only gives me back the Username, TerminalID and Date. I cannot use only that, I need to check ...
0
votes
0answers
22 views

Shell Script for tracking number of times each command executes

How to have a shell script that takes input from /var/log/sudo.log and sends results to a spreadsheet that displays graph for each command execution? I want to record how many times each command ...
0
votes
0answers
21 views

How to list the services I am authorized to start or stop in Linux? [on hold]

I can use the following command in Linux, to list all services: chkconfig --list It lists all services running on that machine. I do not have the privilege to start/stop some of the services. How ...
1
vote
1answer
33 views

dialog menu to display files and select one of them

I want to display all the files under /home directory in menu, and select only one of them. Then the script will print the full path of the selected file. I have created the following script. This ...
4
votes
1answer
227 views

Bash: Variable assignment doesn't seem to 'stick' [duplicate]

I am having a hard time tracking down the reason my 'boolean' flag variable won't stay false when a test fails inside a while loop. The script involves a few loops but essentially it is intended to ...
1
vote
1answer
33 views

maintaining the same filename

I already have a working command to copy a file between different virtual machines. But I want the copied file to automatically have the same filename as the original file. So I want to create a ...
-1
votes
1answer
24 views

shell script - Unable to execute Java with parameters

I have written a shell script that will take a parameter, pass that parameter to Java command. But I get error during the execution. Here is the script: #The script takes an input, the file name to ...
-1
votes
3answers
35 views

Delete oldest files from a directory if number exceeds seven

Daily downloads are stored in a directory. A script has been created which counts how many files reside in this folder. The part I am struggling with is deleting the oldest file in the directory if ...
1
vote
1answer
22 views

A set of libraries like ncurses in a shell script

Supose you present the following TUI in the shell: I need a set of libraries that can be used in the shell to do it. Being sure, ncurses has not been used, because it make a dependecy. Question: ...
1
vote
1answer
40 views

Use case for /usr/bin/lessecho

I can not come up with an example of how I could/would use lessecho. The description in the man page is fairly straight forward but is not helping me come up with a use case: DESCRIPTION ...
2
votes
2answers
42 views

Pass two (piped) shell commands as a parameter to a shell function

I have defined the following shell functions: success() { printf "[\033[32mSUCCESS\033[0m]\n" } failure() { printf "[\033[31mFAILURE\033[0m]\n" } try() { result=$($* 2>&1) if [ $? ...
5
votes
4answers
182 views

How can I cat the contents of files found using find into a single file?

I managed to shoot myself where it hurts (really bad) by reformatting a partition that held valuable data. Of course it was not intentional, but it happened. However, I managed to use testdisk and ...
2
votes
2answers
45 views

Fetching individual bytes from a binary file into a variable with bash

I need to make a fairly simple bash script to pull bytes one at a time from a binary file, send it out a serial port, and then wait for a byte to come back before I send the next one. This is ...
2
votes
1answer
47 views

AIX question on cp command [closed]

I have come across an issue with cp command. We are using ksh and cp command goes like below cp -p $PATH/file_name_${VARIABLE}_???.dat $PATH/file_name_to.dat ??? - is for any three digit numbers. ...
5
votes
1answer
303 views

Determine if Git working directory is clean from a script

I have a script which runs rsync with a Git working directory as destination. I want the script to have different behavior depending on if the working directory is clean (no changes to commit), or ...
0
votes
1answer
31 views

shell script to download info. about movies from imdb/thmb and putting it into an .nfo file for per-use

Does anybody know of a tool which will extract info. from imdb.com/themoviedb.corg and dumping it into a text file ? I have been searching but with no luck . I usually get the movie name but want to ...
0
votes
2answers
32 views

Remove by date in Shell Script

I have a shell script that creates a backup of a database. I would like to keep the last 7 days for files. What is the syntax I need to remove files in a directory by date or can I keep the newest 7 ...
3
votes
4answers
125 views

Test if command accepts a specific option

What is the preferred way to test if a command takes an option? What are the caveats? As a motivating example, at login my shell aliases grep to add several --exclude-dir options but this option is ...
2
votes
2answers
31 views

Change path in sql script with sed

I'm trying to change the path in a oracle sql script from a bash script. read -e -p "Enter the ORACLE SID: " -i "orcl" ORACLE_SID_VALUE sed -i "DEFINE tsdir = '/u02/app/oracle/oradata/orcl';/c\DEFINE ...
0
votes
4answers
34 views

sftp script to get a file from remote machine

I use a script, which contains the line: sftp $FTP_USER@phcsftp.pearsoned.com:/dir/file.txt When I run the script, it asks for my password: user@phcsftp.pearsoned.com's password: However, ...
2
votes
3answers
46 views

Repeat Last N commands [duplicate]

In bash, I tried writing a script to run the last N commands. For say, N=5 for i in {1...5} do !-5 done The problem is that !-5 gets replaced by the 5th-last command on my shell (say time) and ...
2
votes
1answer
15 views

batch tool for sending files over webdav

I know there is cadaver for working with webdav. But it opens an interactive console. I want to write a script that will send files over webdav protocol in a batch mode. What tool can I use?
4
votes
2answers
56 views

Shell script error handling while assigning STDOUT to variable

I am trying to implement error handling in my shell script as described in the 2nd answer in Best practice to use $? in bash? My script looks like this: #!/bin/bash try() { "$@" code=$? ...
1
vote
0answers
30 views

Verbose output in logfile and simple output on screen?

Let's say I have the following script: script.sh and i want the verbose output in a logfile and simple output on screen. Logfile should contain the csh -v script.sh output, and on the screen should ...
2
votes
1answer
44 views

How can I pipe the output of a program or function into a variable?

How can I pipe the output of a program or function into a variable? For example lets say I have this script: function foobarize () { sed \ -e "s|${foo}|${bar}|g" \ $1 } echo foo | ...
4
votes
3answers
104 views

How do I capture stdin to a variable without stripping any trailing newlines?

In a shell script... How do I capture stdin to a variable without stripping any trailing newlines? Right now I have tried: var=`cat` var=`tee` var=$(tee) In all cases $var will not have the ...
3
votes
2answers
50 views

Go up one level from a nonexistent path

I have some code like this in a script (bash) file: if [ ! -d $dir ]; then cd $dir/.. git clone http://... fi Of course as written this doesn't work since $dir does not exist. Is there a ...
2
votes
1answer
18 views

scp (v4) copy from remote to multiple local filenames

I did a bunch of googling and I think what I am trying to do is not possible with openssh/scp v4.x but wanted to ask here in case someone has a creative workaround. I want to copy multiple files from ...
2
votes
1answer
30 views

Installing noip via sh script

I have this script: cd /usr/local/src/ wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz tar xf noip-duc-linux.tar.gz cd noip-2.1.9-1/ make install <<END_SCRIPT Username password ...
1
vote
3answers
230 views

“Can't cd to /home/user” when sourcing a script

I have this script: echo $HOME cd $HOME cd / cd /usr/local/src/ When I run it like this . script.sh I get this output: /home/user : No such file or directory : No such file or directory : No ...
1
vote
4answers
48 views

How to have service that makes sure program keeps running?

I made a service called thin_keep_alive_service in /etc/init.d. I gave it chmod +x rights. The script looks as follows: #!/bin/bash ### BEGIN INIT INFO # Provides: thin_keep_alive_service # ...
3
votes
2answers
97 views

get result text from CLI command

I'm writing a bash script and I need to capture the text resulting from the output of the rsync command, for instance, the following command: rsync -av "$FOLDER1" "$FOLDER2" prints: ... sent ...
12
votes
2answers
428 views

When running a shell script, is it possible to pass specific positional parameters without having to enter them all in order?

For example, if I have script ./foo that takes 10 parameters, and I only want to pass the 8th parameter. The only way I know how to do this currently is: ./foo '' '' '' '' '' '' '' 'bar' Is there ...
1
vote
2answers
58 views

grep works fine in command line but returns nothing in script

I'm trying to write a small script to get me list of files that match certain criteria into a file. #!/bin/sh cd /var/www_data/patch/ grep --include=\*.{php,ini,conf,sh} -ril -P ...
1
vote
0answers
22 views

script started in .xinitrc stays in processes

I have made a little startup bash-script to run before my wm starts. Unfortunately after X and WM is started this script is still listed in the in htop and I don't have a clue why... this is the ...
0
votes
0answers
28 views

Script to compare directories and move files (like rsync)

I use rsync to sync data between two servers. If I completely rebuild the directory structure, rsync cannot understand this and will attempt to recopy everything. I am aware that Unison is capable ...