Questions tagged [shell-script]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
19 views

Variables inside commands inside if statement

I do not understand why this does not work: existing_user=$(ldapsearch -x -b "cn=group,ou=group2,dc=company,dc=com" -H ldap://127.0.0.1 -D "cn=admin,dc=company,dc=com" -w "...
0
votes
0answers
35 views

The HP Chromebook 14a-na0000 have a write protect screw? [closed]

does anyone know how to remove on HP Chromebook 14a-na0000 series BIOS Write-Protect? I want to install windows 10 on an HP Chromebook computer, but i need to disable write protection HP DA00GBMB6E1 ...
1
vote
2answers
41 views

Creating multiple symlinks from a string

I have the following script: #!/bin/bash test="../t1,../t2,../t3" ln -sf "{${test}}" . Above this directory consists of 3 directories: ../ ├── script │   └── test.sh ├── t1 ├── ...
1
vote
1answer
31 views

How to find the first and last occurrence of date field in a log file in linux?

log_file: 2021-08-29 23:25:46,398 IST INFO :......mailslot_create: creating socket for querying route 2021-08-29 23:25:46,398 IST INFO :.....mailbox_register: no mailbox necessary for forward ...
0
votes
0answers
57 views

How to replace eshell.exe with explorer.exe permanently on Windows 10?

A few month ago I did some investigation about the Windows 10 based KIOSK mode and I modified, setup lot of things on my computer. I tested powershell scripts and provision packages. After the ...
0
votes
1answer
21 views

Edit finger so that it does not show no plan

I have a command finger {user} that returns the following: Login: {user} Name: {user name} Directory: /home/{user} Shell: /bin/bash On since Thu Aug 12 11:04 (...
-1
votes
0answers
25 views

How can I use sftp commands when running putty's 'psftp' interface? [closed]

I have a batch file on windows (transfer.bat) with the following command: psftp.exe -i WINKEY_rsa.ppk login@ipaddress -b send.bat In my send.bat I have: sftp login@emts.extra.chrysler.com put TESTEDI ...
1
vote
1answer
49 views

Where am I going wrong with foreach when i try to get my script to run against each individual string in my results?

I have a Users.log file that lists the following information pertaining to Usernames, group memberships and assigned server paths extracted from AD: RandomUser01,RandomGroup01_654321_098765,\\server\...
0
votes
1answer
45 views

Find lines that end with a particular letter

How to grep for lines that end with a letter a or d followed by xy I know that using $ you can check for the ending but not sure how to combine this and use or condition
0
votes
1answer
25 views

How to read multiple words in linux bash script

I am prompting the user to enter two words separated by space. I am using read name to read name and then read last to read last word the user inputs like name last separated by space. But read ...
0
votes
1answer
38 views

How to read excel using Powershell

How to extract data from excel such that in first column having the details of machine and in second column having multiple user name and it read excel like it will delete all users from column 2 ...
0
votes
0answers
83 views

How to fetch the name of all user on remote server which is present at 'C:\user' folder and write that name into Excel file [duplicate]

I am trying to get the name of all users of multiple server through powershell and than transfer it to excel file but I only got the name of user in txt file and unable to copy it to excel. Foreach($...
1
vote
1answer
55 views

pass the variable through SSH and run commands using the variable

Below two files i have trying to execute and I have problem at echo "$application". I dont see get any output. How can I pass the variable through ssh and execute some commands using that ...
0
votes
1answer
30 views

Script won't for more than one group when looking at results of whoami command

Trying to setup IF/ELSE on a script whereby it checks for two conditions to be met before the script runs: Check if the following file exists on the desktop. ($FileExists) Check if the user is a ...
2
votes
1answer
47 views

How can I parse the text from these results into parameters for a separate script?

I need to extract client_TargetText and AnotherTargetText_110953_140521 from the results I get when running the whoami /groups command: Powershell Results: Group Name ...
0
votes
0answers
28 views

Is it possible to use the escape codes used in shell prompts elseware, such as with echo?

Example: When I run echo -e "\[\033[;33m\][\t \u (\#th) | \w]$\[\033[0m\]" The printed response is \[\][ \u (\#th) | \w]$\[\] (Where everything after the first \[ and before the last \] ...
0
votes
1answer
49 views

Speedtest-CLI Cron Job Not Working

Cron job is setup as: */15 * * * * speedtest >> /home/pi/speedtest.log The speedtest script is: #!/bin/sh speedtest-cli --csv >> /home/pi/speedtest.log That uses Speedtest-CLI. The job ...
-1
votes
2answers
43 views

Trying to access current git brach from a windows batch file and put it into variable

I am trying to get the current git branch name into a variable in a windows batch file. To do this I am attempting a for loop through each branch from the output of the "git branch" command ...
1
vote
1answer
71 views

Invoke BitLocker Unlock GUI from a script

In a script, I need a way for a user to unlock a BitLocker encrypted volume. Currently, the user types the password in PowerShell console window ($key = Read-Host 'BitLocker Password for $($path)' -...
0
votes
2answers
23 views

How to check in bash if a function's arguments does not contain any parameters

"Argument" vs. "Paramter" First of all, let me clarify what I mean by: if a function's arguments does not contain any parameters Given the following ls command: $ ls -a ...
0
votes
0answers
29 views

Need expected alignment of linux command output

Please help how should get the below placed Linux command output in below format in single line: "Server_Name","CPU_USAGE_%","MEM_USAGE_%","Drive","...
0
votes
0answers
20 views

How to operate Packages and Inno Setup by script?

I am new in scripting. And I would like to automate my deploying process. And now I am trying to write script which will compile and build installator file by OSX Packages (and for Windows Inno Setup)....
0
votes
1answer
15 views

Pass git stuck options with quotes as-is to a script

I'm trying to write a script that will be called as a git alias. The script is a wrapper around git merge, so I want to pass all it's parameters to git merge as-is when I call it in the script. The ...
0
votes
0answers
22 views

Killing program started by shell script when killing before mentioned shell script

I will start by explaining what I want to do in case someone have a better way of doing it. I am developing an embedded computer running system V. I have a couple of programs that can exit, but which ...
0
votes
1answer
196 views

gpg: can't open 'file.pgp': No such file or directory

I Was decrypting a file.pgp file, and the file is present in the directed. The powershell script is able to read the name of the file but not able to open it. it says below error: gpg.exe : gpg: can't ...
0
votes
1answer
30 views

Script to find the create date of old folders & rewrite it to new folders

I just moved all of my folders/files from an OLD HDD to a NEW HDD. The files on the NEW HDD maintained their created date but the folders now have a create date of TODAY. Can someone please write me a ...
1
vote
0answers
28 views

Simulate "Enter" keypress after successfully making connection using Netcat on Raspberry Pi

I have an issue with using Netcat on Raspberry Pi terminal to output data after making a connection. The issue is that when I run this command, after it is succeeded, 5 seconds pass, and the ...
0
votes
0answers
34 views

Why does Bash require closing some statements?

Something I've always wondered but never gotten around to asking. In Bash: if statements require an ending fi case statements require an ending esac do statements require an ending done (which ...
0
votes
0answers
20 views

Copy a folder from USB to C Drive and then executing the install files using a script

I have been working on a way to copy a folder of files from a USB drive to the computers C drive. It is mostly straight forward but the USB drive's letter can change from computer to computer. So I ...
0
votes
0answers
21 views

list files with ellipsis for continuous range of numbered files

Lets say I have a directory with these files: ➜ ~ ls -1 IMG00.JPG IMG01.JPG IMG02.JPG IMG08.JPG IMG09.JPG IMG10.JPG IMG11.JPG IMG12.JPG IMG13.JPG IMG14.JPG IMG19.JPG IMG20.JPG IMG_forest.JPG IMG_tree....
0
votes
1answer
234 views

When pressed ctrl+c only break out of current function and not whole bash script

I'm trying to write a script wherein if someone pressed CTRL+C (Keyboard interruption) then it shouldn't exit the entire script, just the current execution function. Can anyone suggest what logic can ...
0
votes
2answers
39 views

Clicks "restart" in RDP -> Brings back to my local PC -> I don't know when the RDP will fully wake up -> Whenever it's wake up it login automatically [duplicate]

I have 2 programs in the RDP -- 1)A.bat & 2)B.exe Execution process of A.bat is something like - Step1: Download a file from internet using the command -- powershell -c "Invoke-WebRequest -...
0
votes
3answers
50 views

How to display weeks, days and hours in script

This is a follow-up question to a previous question regarding a bash script I wrote to help me more accurately keep track of my vices. I'm now trying to modify the script to display all non-zero units:...
1
vote
1answer
25 views

Getting audio information using MediaInfo

So if I have a file with audio with the following properties: Language: English Bitrate: 1509 kb/s Sampling Rate: 48.0 kHz Bit Depth: 24 bits Channels: 6 Format: DTS I have wrote the following to ...
1
vote
1answer
47 views

How to make getopts parameter optional

I wrote the following (probably simple) bash script as a budgeting tool to more accurately calculate (and moderate) when I last bought a pack of cigarettes. In addition to -h for printing the output, ...
0
votes
1answer
30 views

How do I make it so that I don't need to source everytime I open up my terminal?

Due to the way I downloaded a certain program [Gromacs], every time I open a terminal to use gmx, I must do the following and would like to make it so I don't need to do this every time: cd ~/...
0
votes
1answer
46 views

Q: how to Get date of file in TCL/TK?

I have a file in linux: -rw-r--r-- 1 quangt alphaa0 8170473 Apr 23 23:06 us_pd_syn_map.log I want to get the date of the file : "Apr 23" How do I get it?
0
votes
1answer
11 views

Declaring a DOMAIN_HOME in setDomainEnv.sh and accessing it using cd

I have declared the following in setDomainEnv.sh DOMAIN_HOME="/opt/NI/Middleware/user_projects/domains/NI_domain" export DOMAIN_HOME but echo $DOMAIN_HOME is not showing the result and cd $...
1
vote
1answer
43 views

Access positional parameters out of order in a for loop

I have a script which makes use of multiple (i.e. positional) arguments from the command line, and within it a for loop that iterates through these arguments: for i in "$@"; do ... done ...
0
votes
0answers
11 views

Is there a work around for how sending standard error to /dev/null affects the behavior of tput?

The script is very simple. Use tput to query the number of columns available. dacracot@nep-vm1:~ $ cat columns.sh #!/bin/bash # determine how many columns are available TERM_COLS=$(tput cols) echo &...
0
votes
1answer
79 views

How to decrease the length of the output of "ps -ef" command? It is showing full output with unlimited length

When running ps -ef command on our new solaris server the command outputs the full arguments of the processes including passwords and usernames. It seems the length of characters it is showing is ...
2
votes
1answer
49 views

/dev/tcp/hostname/80: as an interactive session?

Does anyone know how to obtain an interactive session with the device /dev/tcp/hostname/80? I opened using cat <> /dev/tcp/www.google.com/80 and tried typing in 'GET / HTTP/1.0\nHost: www.google....
0
votes
1answer
544 views

What is awk '{ print $2; }' doing exactly?

I would like to know what is this statement doing exactly, especially the awk part. ps aux | grep 'sidekiq 5' | grep -v grep | awk '{ print $2; }' | xargs kill -${2:-'TERM'} I know the entire ...
0
votes
0answers
18 views

Creating automation script to turn on and off keyboard backlight for macos

i want my keyboard backlight to automatically turn on at 7pm and off at 7am, but i couldn't found any options for that in settings of new macos. so i thought creating a automation script might do the ...
2
votes
1answer
51 views

Cant start apache on mac like i did on windows

I have very simple task to do, since i am not expert in this field i am asking for a help. Right now i am trying to run apache on my mac, i have windows working script and i need basically to do the ...
0
votes
0answers
196 views

Script Shell, integer expression expected

I have to write a script that takes one argument (a directory name) If the number of arguments is more or less than one, the script prints an error message containing instructions how to use the ...
0
votes
0answers
19 views

sed for special charactersand begining and end of string?

sed -e 's/© some text with spaces., string (SS)/do_not_count/g' Yhis command does not work for my scenario neither is it giving any error. Basically, I need to get rid of © some text with spaces., ...
0
votes
0answers
57 views

Running multiple commands in multi-window tmux session as a shell script

I need to run three applications (flask app, node.js app, react.js app) at the same time. So, I wrote the following bash script: #!/bin/bash # A Simple Shell Script To run license plate model server ...
0
votes
0answers
26 views

Create a drag-and-drop operator for a command line script in Lubuntu 20.04LTS

Curious if it's possible to create a launcher such that when I drop a file (an image, in this case) onto the launcher in my desktop, I'll be able to run a bash script on that image. I used to be able ...
0
votes
1answer
27 views

Shell Script : Take filename as an argument and on a standard output display the contents of the file with line number prefixed to it

So, I'm new to shell scripting and I'm trying to write a shell script which takes filename(.txt) as an argument and displays the line number prefixed with each line on a standard output. This is the ...

1
2 3 4 5
27