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

learn more… | top users | synonyms (2)

1
vote
0answers
12 views

Shell command works locally but does not get parsed correctly through ssh

If I execute the following shell command locally, I get the expected result: adb -s 123456789 shell "su -c 'mount -o remount,rw /system;rm -r /system/app/MyApp.apk;cp /sdcard/MyApp.apk ...
3
votes
1answer
21 views

Why do I get an error when double quoting single quotes in a script that launches a remote SSH command?

I have this script: port=$1 cmd=$2 ssh root@127.0.0.1 -p $port "'"$cmd"'" When running myscript.sh 1000 "ls /dev/shm" it get this error: bash: ls /dev/shm: No such file or directory In the ...
1
vote
2answers
58 views

Extract text from one iteration of top

I want to execute the top command from my bash script the problem is that usually when I type the top command on the console , I exit by Ctrl+C. but how to exit from top when I run the top command ...
1
vote
0answers
47 views

extracting data from a log file and plotting it using Gnuplot

I have a logfile with the following data in it: Sat Sep 20 11:25:01 BST 2014 -- temp=53.0'C -- message from script /usr/src/scripts/wifi_test_2.sh Sat Sep 20 11:26:01 BST 2014 -- temp=53.0'C -- ...
5
votes
3answers
592 views

Cron to not run on specific day but all other days

I have a cron setup to execute a bash script daily at 10pm. I have another cron setup to run monthly on the 1st of the month. Both crons launch a bash script, and the only different in the bash script ...
-6
votes
2answers
181 views

Shell script to compile C files

I used to have a shell script that would compile all of the FILE.c files in a directory to FILE.out I lost it and am trying to remake it and have the following which I know is very similar but can't ...
0
votes
2answers
52 views

scp with password and renaming the file [on hold]

I need to execute scp command with renaming the file. I have tried with following code: HOST=lnx25 USERNAME=ngqa PASSWORD=xxxxx FILE=$1 FILE_NAME=`echo $FILE | awk 'BEGIN{FS="/"} {print $NF;}'` ...
0
votes
1answer
308 views

How to track SFTP's error

I have 1 script which is used for SFTP. I am getting error for permission issue on target server. I want to track this error in log file. How i can track the sftp's error. below is my code, sftp ...
-2
votes
0answers
26 views

Simple shell script [on hold]

So I need some help with writing a simple shell script that will allow a user to display a list of current users. It isn't homework and i'm not looking for a completed code, just help to how i'd go ...
-1
votes
0answers
21 views

Update file values with another file [on hold]

I have a file named /work/Target/IB/USSALESCOMP/ODS_INCR.prm as below $$Firm_INCR_DATE=09/05/1992 $$Branch_INCR_DATE=01/01/1900 $$Payee_INCR_DATE=01/01/1900 $$PRODUCER_INCR_DATE=01/01/1900 I ...
-5
votes
0answers
31 views

shell script to read a log file and display in a readable / good format [on hold]

I need to read a log file which contains date,time,error_name, pid,program crash details and others content. log file is supplied as input file to the script and output should display in following ...
0
votes
3answers
153 views

How to add a password to a specific command

I've been searching google on how to add additional security to a specific command without using sudo. Is it possible to add on a security feature without actually using sudo? For example: Whenever ...
0
votes
1answer
2k views

Why does scp say “No such file”?

I have a bash script that uses scp to copy a file from my machine to another. The script keeps on exiting after I enter the SSH password with the error: <filename>: No such file or directory ...
3
votes
2answers
306 views

Using grep in a if-else statement [on hold]

Why my code isn't outputting if a string entered isn't in the file. When I enter a string and it isn't in the file, there's no response back, it re-loops back to the beginning. Can someone tell me ...
2
votes
3answers
1k views

QEMU do not start when executed in background inside shell script

I have an application that runs fine, with and without '&' when run directly from the terminal. However, if I try to execute it from a shell script, it works only if the trailing '&' is ...
0
votes
2answers
471 views

“Expect” automation tool output to shell variable

#!/bin/bash # more commands here expect << EOD spawn telnet localhost 9151 expect -exact "Trying 127.0.0.1...\r Connected to localhost.\r Escape character is '^]'.\r" send -- "AUTHENTICATE ...
0
votes
0answers
22 views

Loading csv data into hbase table in multiple columns using flume [on hold]

Is anyone know how to sink spool directory's .csv file data using flume to hbase i.e splitted columns into the hbase ? CSV File Format Data is: sample.csv ...
3
votes
1answer
22 views

More shell scripts than one in one text file?

I am learning shell scripting for my introductory UNIX course at my university, and I`m curious if is it possible to have more than one shell script in one text file. What I mean by that is, for ...
2
votes
1answer
21 views

Single or double brackets and portability

I have found some very good answers here on the differences between [ and [[ in 'if' statements. For specific named shells, it seems to be a good idea to use [[ over [ (and it is faster, too). I'm ...
2
votes
2answers
41 views

How to run the dialog command with proccess?

NOTE: Please look at my code, it's a Bash script. I want to display both dialogs on the screen at the same time, one dialog displays this: tail –f from - /var/log/proccess1.log and the second ...
2
votes
1answer
30 views

Prevent SIGINT from interrupting function call and child process(es) within

Consider the following script: #!/bin/bash set -o pipefail set -o history trapper() { func="$1" ; shift for sig ; do trap "$func $sig" "$sig" done } err_handler () { case $2 in ...
1
vote
1answer
27 views

Reload .bashrc file for parent shell

I'm creating a script for managing my dotfiles and I want to source my ~/.bashrcfile automaticaly for the current bash. But I found that when in my script write : source ~/.bashrc it will source ...
3
votes
1answer
12 views

Preventing mid-word line breaks in a2ps

So I understand that a2ps is mostly for converting ASCII code to postscript for printing, but occasionally I like to print a .txt or .md file for school. Often, an entire sentence (or even a ...
2
votes
1answer
24 views

Comparing delimited fields

I have two fields in a file, students and teachers. They're delimited by a semicolon and I want to find which single students have two different teachers. jdoe;ateacher jdoe;bteacher jsmith;cteacher ...
0
votes
3answers
61 views

Combinatorics of letters and words - preferably bash, will accept perl or other

I am trying to write a shell script to generate all possible words in the English language less than 20 characters. I doubt there is any truly efficient way to do this other than to brute force some ...
1
vote
1answer
29 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
1answer
797 views

How to strip color codes out of stdout and pipe to file and stdout

I have a program that uses printf with some tput mixed in it and I'd like to pipe the output to stdout as well as a file. I'd prefer to use sed since I don't want any unnecessary dependencies on my ...
1
vote
2answers
48 views

finding latest date and date modified file and using sed

I have a series of files that contain a date and I need to get the file which has the latest date, and the latest date modification and pipe it to sed. I have tried various approaches and I cannot ...
-1
votes
1answer
113 views

Commands not found in shell script

I need to execute scp command without using expect command in script. How to use scp with password? I have tried with following code. HOST=lnx1 USERNAME=user PASSWORD=pwd PATH=/sample/data/ FILE=$1 ...
1
vote
2answers
37 views

Pass arguments to a command run by another user

I have a bash script that is supposed to take some arguments and then run in a different user: test.sh #!/bin/bash sudo su user2 <<'EOF' echo $1 EOF However it prints blank: $ ./test.sh ...
0
votes
3answers
37 views

how to generate only one special character in this password generator

I have a command which generates password with multiple special characters. How can I make it to generate only 1 special character? # Generate a random password # $1 = number of characters; defaults ...
2
votes
5answers
3k views

script to scan ip range and return results in a certain format

This script scans IP's and returns a status of Up or Down. How can I alter it so it doesn't scan everything twice? As it sits it scans everything and returns the "Up" addresses only and then scans all ...
3
votes
3answers
155 views

Having an issue searching for a string in a file

I have tried to use a 'case' loop but it doesn't work for a reason unknown to me. This is my script for the case loop. echo "Do you wish to search again? [y/n]" read INPUT_STRING2 case ...
0
votes
0answers
23 views

Help with creating random passdown [duplicate]

This is the command I am issuing to generate password that has capital and lower case letters numbers, numbers and only 1 special character. I can't get it to work, can some one on what is that I am ...
11
votes
4answers
3k views

Executing user defined function in a find -exec call

I'm on Solaris 10 and I have tested the following with ksh (88), bash (3.00) and zsh (4.2.1). The following code doesn't yield any result: function foo { echo "Hello World" } find somedir -exec ...
0
votes
3answers
2k views

How do you create and execute a bash script which calls an executable from higher folder?

I'm attempting to write a very simple script which calls an executable from a higher level folder. If I were just typing the command into the console, I would type ../filenamehere {options} ...
2
votes
3answers
43 views

Copy files by date/time order contained within filename?

I have a bunch of files with a pattern like this: {UID}-YYMMDD-HHMMSSMM-NEW.xml Or a real example: 56959-140918-12465122-NEW.XML I want to copy these files to another directory in date and time ...
1
vote
0answers
32 views

tput command + how to locate dialog window on the top of the screen

Is it possible to use the tput command in order to place the dialog window on the top of the screen ? For example The following dialog command display the log is running by tail command dialog ...
0
votes
0answers
31 views

bash + timer in dialog window

is it possible to insert the following code ( timer ) in the dialog progress bar ? date1=`date +%s`; while true; do echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r"; done ...
1
vote
3answers
82 views

How can I select columns based on a control file with invalid column numbers?

I have to generate the file dynamically from the source file based on the below control file. control_file.txt 1,3,5,-1,8,-1,4 The control file contains the position of columns which I require ...
4
votes
5answers
156 views

Clone directory tree structure and copy files to the corresponding directories modified after a specific date

I have a folder with more than 30 sub directories and I want to get the list of the files which was modified after a specified date(say sep 8 which is the real case) and to be copied with the same ...
0
votes
0answers
28 views

How to get diff for HTML reports?

echo "New defects" echo "===============================" n=0 def_num=0 while read line; do n=$((++n)) if echo $line | grep '^[[:space:]]*>' &>/dev/null; then if [ $(($n % ...
2
votes
2answers
38 views

Output piped content to file and show number of lines in the file on stdout

I would like to use tee to pipe content from stdout and stderr respectively into files (in fact append it with > >(tee -a $filename)). However, instead of seeing the contents appended to the ...
10
votes
2answers
243 views

Having a problem with a shell script counting characters

I'm trying to learn the basics and I have run into an issue with my script counting the characters of a user's input. Here is my script, can someone point out where I'm going wrong please? ...
1
vote
1answer
23 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 ...
2
votes
2answers
52 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: ...
1
vote
2answers
60 views

How to grab output from command in shell script [duplicate]

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
1answer
434 views

Starting Resque worker with script doesnt work, starting by hand does

I am trying to figure out why my process doesn't work if started via a script, but works fine if started by hand. Here's the details: script is a resque worker start script. The script location is ...
0
votes
1answer
18 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 ...
0
votes
0answers
24 views

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

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 ...