scripting

Bash: how to check if there is only one root id and all user UIDs are unique?

北慕城南 提交于 2019-12-13 08:07:23
问题 i have this bash script here that i'm trying to modify to check if there is only one root id, is it vulnerable and currently, this script only checks if there is a duplicate uid and display the users that shares the same uid. Thanks in advance! :) Bash Script: #!/bin/bash /bin/cat /etc/passwd| /bin/cut -f3 -d":" | /bin/sort -n | /usr/bin/uniq-c | while read x ; do [ -z "${x}" ] && break set -$x if [ $1 -gt1 ]; then users=`/bin/gawk -F: '($3 == n) { print $1 }' n=$2 /etc/passwd| /usr/bin/xargs

How to remove EOF empty line created by sed [duplicate]

邮差的信 提交于 2019-12-13 08:05:30
问题 This question already has answers here : How can I delete a newline if it is the last character in a file? (22 answers) Closed last year . I'm using sed to modify the first part of a text file. The problem is that sed automatically introduces a empty line at the end of the file. Do you know how to solve that? (Not using truncate, as I do not want to install additional software in MacOS) Thanks!! 回答1: A quick answer to your question would be to pipe your output to another cmd like awk : sed

Shell command on each line of file

谁都会走 提交于 2019-12-13 07:42:34
问题 I am trying to write a Perl script which will do the following: 1. Open a file which, in each line, contains the location of multiple files (Say File A, file B) 2. Do an egrep on each of these files something like egrep "module|input|output" 3. Store the output of the egrep with the same file name A, B etc but in a different directory) There are more constraints on the egrep, but I can add them later. My question is how do I do steps 2 and 3? Where in, I execute a shell command on each line

Writing Automated scripts to configure device

久未见 提交于 2019-12-13 07:20:04
问题 My requirement is like this: I need to log in to a remote device (say Router/switch) and execute following commands. telnet xx.xx.xx.xx //give password here sys interface g x/x/x shut desc free-port exit There are Hundreds of devices for which I cannot waste time doing above damn thing 100 times. I need to write a automated script which does it. so My questions are as follows: I use Windows system, so What is the best scripting language to be used : Ruby / shell script / perl ? (I was

Split own filename and assign specific parts to variables in a batch script

橙三吉。 提交于 2019-12-13 07:18:53
问题 thanks in advance for any help offered. I have a batch file from which name i want to use parts and assign them as variables. Using the for /f with delims i was able to do something like it but i have to rename the file to a different scheme than what i need. Se here is what i have: -Current filename: WHID-PRT-MFP-3, NORTH EAST OFFICE.bat SET getname=%~n0 for /f "tokens=1 delims=-" %%G IN ("%getname%") DO (SET siteid=%%G) for /f "tokens=1 delims=," %%E IN ("%getname%") DO (SET name=%%E) SET

How to access and edit globals in Roslyn scripting environment?

本秂侑毒 提交于 2019-12-13 07:15:29
问题 I have an application in which I use the Roslyn scripting engine (namespace Microsoft.CodeAnalysis.Scripting ). What I have right now is this: public static async Task<object> Execute(string code, CommandEventArgs e) { if (_scriptState == null) { var options = ScriptOptions.Default; options .AddReferences(typeof (Type).Assembly, typeof (Console).Assembly, typeof (IEnumerable<>).Assembly, typeof (IQueryable).Assembly) .AddImports("System", "System.Numerics", "System.Text", "System.Linq",

Iteration: Powershell Output

≡放荡痞女 提交于 2019-12-13 07:00:07
问题 I am having trouble getting the right PowerShell output. An example of the Output is as follows: ComputerName | Drive | Size | Free | PercentFree COMP-NAME H: 249 11 4.5 ComputerName | Drive | Size | Free | PercentFree COMP-NAME C: 67 3.2 4.7 ComputerName | Drive | Size | Free | PercentFree COMP-NAME H: 249 11 4.5 ComputerName | Drive | Size | Free | PercentFree COMP-NAME C: 67 3.2 4.7 ComputerName | Drive | Size | Free | PercentFree COMP-NAME H: 249 11 4.5 ComputerName | Drive | Size | Free

How to capture running log using bash script? [Case Closed]

烂漫一生 提交于 2019-12-13 06:32:21
问题 I'm a new player in bash scripting. There's something that I want to know about capture logfile using bash script. Let's say there is a server which store logfile every hour with format file below. file[20160509_130000].log The logfile has detailed information like this. 13:00:00 INFO [file.chdev130] Event: ADIEVN_PLAY_DONE, Finished , nbytes=16360 13:00:00 INFO [file.chdev39] adiCollectDigits() success My question is how can i read and store the running log or one hour before to get specific

a regular expression to grep specific paragraphs of a file

五迷三道 提交于 2019-12-13 05:51:49
问题 hi i am working on a shellscript.. suppose this is the data my shell script runs on Ownership o Australian Owned ? Ads for Mining Engineers 232 results for mining engineers in All States filtered by Mining Engineers [x] category * [ ] [34]get directions Category: [35]Mining Engineers [36]Arrow Electrical Services in Wollongong, NSW under Mining Engineers logo [37]email [38]send to mobile [39]info Compare (0) * [ ] . [40]Firefly International Designers & Manufacturers. Service, Repair & Hire.

IE 8 - script to update browser configuration

被刻印的时光 ゝ 提交于 2019-12-13 05:44:23
问题 For the deployment of a specific Web application on IE (from 6 to 8, but let's concentrate on the 8), I need to set some specific security settings. There are a lot of them and some are touchy (well, not that much but all my users don't talk computer fluently :-) ), so I'm looking for a kind of batch (an .exe, a .bat, a .reg possibly if these parameters can only be set in the Register DB, the best being a .NET app) to set them via a single double-click before the deployment. Thanks for your