2018-10-21         Joan

How to debug rc.d scripts in FreeBSD?

I have a bash script in my /usr/local/etc/rc.d/that should run python script. I run the bush script withservice script_name startand nothing happens at all. How could i debug that rc.d script? How could i know what is going on? FreeBSD rc.d system expects /bin/sh scripts. Hence sh debugging techniques apply here. For example printing the statements with set -x and set -v.# cat script.sh#!/bin/shset -xset -v...Below is a simple example how to start my_app with the service command# cat /scratch/my_app#!/usr/local/bin/bashcase $1 in start) echo "Start my_app" ...

 shell                     1 answers                     85 view
 2018-10-21         Lisa

at command does not work

When I run this code the shell script does not work. sudo at -t 200201010102 -f /test.shThe output of date command is:Tue Jan 1 01:00:01 IRST 2002The script is:#!/usr/local/bin/bashshutdown -r nowThe user that I run the at is test. I give the permission in sudoers file to the user test.when i run the command it has no error. At the given time I execute atq and the job disappear correctly.what is wrong?Thanks Use the following date-time format: at -t 200201010210 -f /test.shRun the job at time, given in the format YYYYMMDDhhmm[.ss].YYYY-year(2002)MM-month(01)DD-day(01)h...

 shell                     1 answers                     92 view
 2018-10-21         Shirley

Unix command to get list of directories over remote host

I am trying to do ssh to a remote machine and get list of directory names present at pathA(/home/abc/mydata) which has any file that has been modified in last 1 hours.Directory:- /home/abc/mydata -> Directory a ->file1 last modified 1 hour back ->file2 last modified 1 year back ->file3 last modified 1 day back -> Directory b ->file11 last modified 1 year back ->file22 last modified 1 year back ->file33 last modified 1 year back ->Directory b1 ->fileb1-11 last modified 1 ho...

 shell                     2 answers                     26 view
 2018-10-21         Sigrid

ESXi shell scripting getting rid of a message

I'm working on a small VMware ESXi project (personal project, not for any company).Im trying to build a html file that contains a table with some information from ESXi OS, like time/date, OS version, patch number, etc.However there are some commands that give no output and then my table has an empty box (cell).What i am trying to do..and terribly failing at ...is that i am trying to put a simple if-else-fi statement in the shell script that would check if the output is empty or not.Here is the command i use the check if there is an output to the command or not:if [ $(esxcli...

 shell                     1 answers                     50 view
 2018-10-21         Quinn

zsh truncates previous stdout when prompt width is same as COLUMNS

I have this simple zshrc which displays time in prommpt and resets it every 1 secondbelow is simplified version of my zshrc repeat_string(){ # this works fine printf "-%.0s" $(seq 1 $(( $COLUMNS - 1))) # this doesn't works fine # printf "-%.0s" $(seq 1 $COLUMNS)}TMOUT=1TRAPALRM() { PROMPT="$(repeat_string) $(date) hello >>>" zle reset-prompt}I have simple function here repeat_string which I'm calling in my prompt string. purpose of this function is to display seperator (-) which has length equal to column width. It works fine when I pass repeat count which ...

 shell                     1 answers                     99 view
 2018-10-21         Jo

How to determine if the tcsh script is being sourced within the script [tcsh, not bash]

How can I determine if the current tcsh script is being sourced (within the script)? What I tried:if (!($0 == "-tcsh")) then echo "Script should be sourced." exit 1endifIf I'll try without source it will print Script should be sourced. (As expected).But If I'll try with source, it will fail with the following error: if: Malformed file inquiry..How can I fix this problem? Is there a better way to check it? There is a nasty trick you can play here by looking at $_. $_ Substitutes the command line of the last command executed.If you place this in the first line of yo...

 shell                     2 answers                     55 view
 2018-10-21         Leo

Unable to Pass option using getopts to oozie shell Action

I created a script in shell and passing the arguments using getopts methods in my script like this:sh my_code.sh -F"file_name"where my_code.sh is my unix script name and file_name is the file I am passing to my script using getopts.This is working fine when I am invoking my script from the command line.I want to invoke the same script by using oozie, but I am not sure how can I do it.I tried passing the argument to the "exec" as well as "file" tag in the xml When I am trying passing argument in exec tag, it was giving "JavaNullPoint" Expectionexec TAG<exec>my_code.sh ...

 shell                     2 answers                     83 view
 2018-10-21         Jerry

Getting definition of -f Linux flag tougher than expected

Terminal beginner here. I was reading through a tutorial and encountered the following command: rm -f src/*For my own edification, I want to know what -f does. However, when I enter in man -f, I get the error response What manual page do you want? and when I run man f, I get the response No manual entry for f. What's the correct way to get the definition of -f in this context from the terminal? -f is parameter of the rm program. It doesn't have same meaning for all programs so you have to look manual page of the program. man rm in your case and it says:f, --forceignore n...

 shell                     2 answers                     11 view
 2018-10-21         Renata

Checking connection to two servers in shell using nested loops

I have docker environment defined in docker-compose.It has 3 containers. Two with databases and a third with cli script interpreter.3rd container has to wait for 2 db containers to accept connections.It was quite simple when I had just one db container.3rd container ( Alpine based ) entrypoint.sh:#!/bin/shwhile ! nc -z $MYSQL_HOST $MYSQL_PORT; do echo "Waiting for MySQL to accept connections ..." sleep 0.2doneecho "MYSQL ready"exec "$@"Now with the second container I would like to solve this using nested loop but since posix shell does not in general support arrays I ...

 shell                     3 answers                     21 view
 2018-10-22         Mortimer

import json file produced from _search to elastic search using shell script

I have generated json in ElasticSearch by running a range query and it generates in following format :{ "took" : 63, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : 1000, "max_score" : null, "hits" : [ { "_index" : "bank", "_type" : "_doc", "_id" : "0", "sort": [0], "_score" : null, "_source" : {"account_number":0,"balance":16623,"firstname":"Bradshaw","lastname":"Mckenzie","age":29,"gender":"F","address":"244 Columbus Place","employer":"Euron","emai...

 shell                     1 answers                     43 view
 2018-10-22         Kim

Jenkins Docker Run and Sh script concurrently

Is there a way to run a shell command during docker run without using the docker file? What I have right now is this, but it seems to start the container and then run the sh script afterwards. What I need to do set up a user during container running time because it runs with super user privilege (correct me if I'm wrong). node('linuxNode') { docker.image('docker/repo').inside( '--privileged ' + '--volume "...") { sh '/home/path/to/script/createNewUser.sh' }} Fixed my issue, before I was giving argument in '-v ____ ' + '-v ____ ' + ... form...

 shell                     1 answers                     40 view
 2018-10-22         Belle

A hint for end of ASCII data in a binary file

I'm developing a software that stores its data in a binary file format. However, as a courtesy to innocent shell users that might cat to inspect the contents of such a file, I'm thinking of having an ASCII-compatible "magic string" in the start of the file that tells the name and the version of the binary format.I'm thinking of having at least ten rows (\n) in the message so that head by default settings doesn't hit the binary part.Now, I wonder if there is any control character or escape code that would hint to the shell that the following content isn't interpretable as pr...

 shell                     1 answers                     31 view
 2018-10-22         Elizabeth

How to provide an input to ftp terminal directly from the script

I am trying to ftp a set of files to a client server. I tried automating it using ftp since we dont have SSH key setup yet. I have stored the destination host (Name, UN, PW) in .netrc file. When the script is executed, it opens up the ftp terminal and stops. How is it possible to continue the script post opening the ftp terminal ? Can you guys help ?#!/bin/kshcd /scripts. ./getYesterdayDate.shtoday=${YESTERDAY_DT}today=`echo $today | sed 's/-//g'``echo "Today is $today"#Copying file from Source server/usr/local/bin/scp UN@HOST:/backup/abc*.$today /scripts#Renaming the files...

 shell                     1 answers                     88 view
 2018-10-22         Mandel

groovy + shell : Escaping characters

I am using Jenkins Pipeline using Groovy sandbox. And i am trying to run a shell script in a groovy sh function.The original shell script is sed -i 's/sometext/'"${othertext}"'/' filenameI am trying to replace a particular text with other text (taken dynamically). The script works fine when executed directly.But I want to use it in jenkins groovy sh function.sh(script: '<above shell script>', returnStdout:false)But there is a problem of escaping characters.I tried this way of escaping charactersh (script: '''sed -i 's/sometext/othertext/' filename''', returnStdout:fa...

 shell                     3 answers                     52 view
 2018-10-22         Morton

Set environment variable while referencing another

I'm trying to set an environment variable in a docker container and have it persist. Running ENV PATH=${PATH}:${HOME}/my_dirResults in :/my_dir being appended to the path, which is not what was intended.However PATH=${PATH}:/home/my_user/my_dir correctly appends :/home/my_user/my_dir to the path.What must be changed to avoid typing the absolute path? ${HOME} is set by shell, when you build docker image with ENV, no shell there, so the value certainly be empty.Try next:ENV PATH=${PATH}:~/my_dir~ will be interpreted as HOME in container run time. [XXX]

 shell                     1 answers                     53 view
 2018-10-22         Jocelyn

AWK file conversion

I have a file in the below format:Total:89.3 User: user1 Count:3 Sum:80 departmentId: dept1 Amount by departmentId: 20 departmentId: dept1 Amount by departmentId: 35 departmentId: dept2 Amount by departmentId: 25 User: user2 Count:3 Sum:7.199999999999999 departmentId: dept1 Amount by departmentId: 2.4 departmentId: dept2 Amount by departmentId: 2.4 departmentId: dept3 Amount by departmentId: 2.4 User: user3 Count:1 Sum:0.2 departmentId: dept2 Amount by departmentId: 0.2 User:...

 shell                     2 answers                     59 view

Page 1 of 135  |  Show More Pages:  Top Prev Next Last