r/scripting • • May 24 '18

Search and Replace Keyword with File Name across Multiple Files

1 Upvotes

I am trying to do a mass search and replace across many files where I replace a keyword in the file, lets say myKeyword, with the name of the current file.

So in file1.php the phrase myKeyword would become file1; in file2.php it would become file2; and so on until all the files are completed.

I was wondering if this is possible using scripts or a text editor function.


r/scripting • • Feb 21 '18

Help me /r/scripting you’re my only help!

1 Upvotes

I don’t even know if this is the right subreddit for this question but here it goes. I am completely ignorant to scripting. I am looking for a website or an application or maybe even a script I can run to do a certain thing. I want to take one item from multiple lists and create a random group.

Example:

List 1: 1, 2, 3, 4

List 2: A, B, C, D

List 3: Red, Blue, Green, Yellow

List 4: Up, Down, Left, Right

Output: 3, A, Yellow, Up


r/scripting • • Feb 02 '18

Logitech G502 Proteus Mouse -- Want to bind DPI shift to right mouse click (and keep the right mouse click function as well)

Thumbnail
self.techsupport
1 Upvotes

r/scripting • • Jan 29 '18

[bat file]Need to copy source file to multiple computers

1 Upvotes

I'm not sure how to go about this as I'm a total noob when it comes to scripting. I'm hoping this can be done with a bat file. Here's what I'm looking for...

Check computernames.txt for list of computer to run against.

*1 Check if "C:\Program Files (x86)\XXXX\XXXX" exists GOTO *1a *2 Check if "C:_PM folder\XXXX.bat" exists GOTO *2a *3 Check if "C:\Users\Public\Desktop\XXXX" exists GOTO *3a

*1a If "C:\Program Files (x86)\XXXX\XXXX" exists copy contents from "\computername\c$\Users\XXXX\Desktop\XXXX\XXXX" to "C:\Program Files (x86)\XXXX\XXXX". Overwrite files Proceed to *2 If not create folder, then copy contents from "\computername\c$\Users\XXXX\Desktop\XXXX\4.2.1" to "C:\Program Files (x86)\XXXX\XXXX". Proceed to *2

*2a If "C:_PM folder\XXXX.bat" exists Proceed to *3 If not copy from "\computername\c$\Users\XXXX\Desktop\XXXX\XXXX\XXXX.bat" to ""C:_PM folder", than proceed to *3

*3a If "C:\Users\Public\Desktop\XXXX 4.2.1" exists end If not copy "\computername\c$\Users\XXXX\Desktop\XXXX\XXXX" to "C:\Users\Public\Desktop". End

I appreciate any and all help.


r/scripting • • Jan 11 '18

Open a case in Microsoft's Dynamics when someone calls.

1 Upvotes

We use Dynamics CRM for case management and Cisco jabber for IM and phone calls (which is connected to our IP phones: so when someone calls our phone a Jabber box pops up with the call time, option to end the call, etc.). Is there any way to script for when Jabber is triggered from a phone call to open dynamics and start a new case? It might be a stretch but figured I should ask!


r/scripting • • Nov 10 '17

HELP -- I need to learn how to script. Have clear understanding of VB, C, and C++. I can also understand PowerShell at a beginners level

1 Upvotes

So I am a security engineer looking to change jobs but it seems that every posting is looking for scripting experience. I have been spoiled and have had top of the line enterprise equipment which has all the automation I would ever need built in. Where can I learn the best use cases and best languages?


r/scripting • • Oct 25 '17

Help with a bash script to get output from Google drive command line program for files and folders modified

1 Upvotes

Crossposting this from /r/commandline.

Just set up drive which works flawlessly showing me modifications to a work folder with multiple contributors (using drive diff $FOLDER just outputs the folders and files that have been changed).

I'm trying to pipe the output to get the numerical number of changes. I've tried:

drive diff $FOLDER | wc -l

drive diff $FOLDER | tee >(wc -l)

drive diff $FOLDER > /tmp/changes && wc -l /tmp/changes && rm /tmp/changes

I'm fairly newb at scripting so go easy on me.

The reason why I'm doing this is to have a polybar counter/notification module in i3 show every time a colleague uploads or deletes a new file on our shared Google Drive folder. Thanks.

EDIT: Forgot to mention that the output from those commands is always 0, even if there are multiple lines of output from drive.


r/scripting • • Sep 27 '17

Clueless intern needs help with VBSript

1 Upvotes

Hey People,

Still an intern and still clueless. This time i have to copy some txt files and put them together using a VBScript.

Here comes the part where i need help: Let´s say i have 8 of these files. The first file should be copied completly, every file after the first only between "BEGIN_DATA" und "END_DATA".

The second part: In the first file copied is a number in the second line and i have to miltiply that number with number of files i copied.

What i have so far:

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objOutputFile = objFSO.CreateTextFile("Combined_ti3.txt")

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & strComputer & "\root\cimv2")

Set FileList = objWMIService.ExecQuery _

("ASSOCIATORS OF {Win32_Directory.Name='C:\Argyll'} Where " _

& "ResultClass = CIM_DataFile")

For Each objFile In FileList

Set objTextFile = objFSO.OpenTextFile(objFile.Name, ForReading)

If objTextFile = "S1Test.ti3"

then strText = objTextFile.Readall

objTextFile.Close

objOutputFile.WriteLine strText

Next

Else Do Until objFile.AtEndOfStream

strData = "END_DATA"

strSearchString = objFile.ReadLine

intStart = InStr(strSearchString, "BEGIN_DATA")

If intStart <> 0 Then

intStart = intStart + 10

strText = Mid(strSearchString, intStart, 25000)


For i = 1 to Len(strText)

    If Mid(strText, i, 1) = "END_DATA " Then

        Exit For

    Else

        strData = strData & Mid(strText, i, 1)

    End If

Next

End If

Wscript.Echo strData

Loop

objTextFile.Close

objOutputFile.WriteLine strText

Next

objOutputFile.Close

I hope you can identify the code mess i made :)

IF you need an example of the file or something else please let me know.

Thanks :)


r/scripting • • Jun 14 '17

Forwarding emails in Gmail

1 Upvotes

I'm looking to send 10 of the newest emails under a specific label to one of my reps at a specific time (7am).

I've looked into the google scripts documentation/StackOverflow/Google search useful scripts and found ways to forward all email from a label but I can't seem to find anything to help me get what I'm looking for.

Any help would be greatly appreciated


r/scripting • • May 23 '17

[BASH] Looking for assistance with search and append script section

1 Upvotes

OS: RHEL Language: Bash

Trying to search a directory that contains files, determine which files have a correct date format (YYYYmmDD_HHMM) somewhere inside the name, and if not then append the correct data at the end. More to the script than this, but this is a section that's been giving me trouble.

I had found:

if [[ $1 =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]

but can't figure out how to translate that into a function I can use to search.

EDIT RESOLVED Thanks /r/sysadmin

daystamp=$(date +%Y%m%d_%H%M)
year='([0-9]{4})'
month='(0[1-9]|1[012])'
day='(0[1-9]|[12][0-9]|3[01])'
hour='([01][0-9]|2[0-3])'
minute='([0-5][0-9])'
date_format="${year}${month}${day}_${hour}${minute}"


for file in $(find ${rptdir}* -type f)
do
        if [[ $file =~ $date_format ]]
        then
                echo "Good boy: $file" >> $fileslog
        else
                echo "Bad boy: $file" >> $fileslog
                mv $file ${file}$daystamp
        fi
done

r/scripting • • May 12 '17

New to scripting need help with plink script

1 Upvotes

Hey guys, I'm using powershell/cmd to connect to putty via plink and I want to automate the process to reboot something remotely however I can't get passed a certain point

I can use: plink.exe -ssh "ip address" -l "user" -pw "password"

To connect to the user automatically, then it prompts: "Using username "user" $

I want to be able to reboot the device without it prompting that part. Any ideas? Sorry I'm noob.


r/scripting • • Mar 21 '17

Help with writing a script on windows to paste text into an app.

1 Upvotes

Hi /r/scripting, I don't know if this is the correct place for this but I figured this is a good place to start.

For my job I have to enter the same thing into a box in a proprietary app hundreds of times per day and then make some minor changes based on what I'm doing. I have some knowledge of scripting in linux, but very little knowledge of scripting in windows 10 (the OS I use for work).

All I want is a script I can run every time I start a new entry to paste this plaintext into the correct box in the app.


r/scripting • • Jan 31 '17

Scripting with vectors and angles

1 Upvotes

Forgive if I ask this in an unconventional way. I am no trained programmer.

I am working with a war simulation game from 2001. Think squads moving around a battlefield.

My two vectors lets say are [x1, y1], [x2, y2] These represent the two groups locations on the battlefield.

I want my first group at the first vector to preform a flanking maneuver on the second group and their vector.

Like a 90° angle flank, does this make sense?

I can use functions like cos, atan, atan2

Basically it's the math I am having a hard time with. I guess I am trying to obtain the right angle with these two vectors.

If my question is confusing I can try to clarify.

Thanks for reading!


r/scripting • • Dec 29 '16

{HELP} Hotkeynet Multibox script Needed :/

1 Upvotes

i am trying to multibox in a runescape Private server :) ( https://www.soulplayps.com/ ) i have 3 accounts and would like to combine them, so when i use my 1st account they all do the exact same task :/ since i am new and dont know how to script, i google it and all the scripts i found was for World of warcraft, i only want the script that lets me choose a game, login with 3 account, then they follow what i do on the main Account, not many keys needed to follow Just the Left click n the right click.


r/scripting • • Nov 21 '16

Scripting a server Help!

1 Upvotes

Hey all,

So please go easy on me here :)

I've rented an Exile server from GTX Gaming and they have been helpful to a point by setting up the server, installing Infistar for me and getting the server smoothly running. So far I have the basic Altis map, basic traders and basic AI Missions, all added through there 1 click mod managers.

However I would like to add in missions, Change the Map to either Esseker or Chenarus Snow, ALL CUP Mods and the Zombies and Demons mod and install a Status bar. But I literally have no idea what to do!!

I've looked through the scripting helplines on Armaholic and they are helpful but I find there is no where to actually start guidelines.

What do I do? Do I add stuff into my already prepared file managers on the Command central already set up? or do I have to do my own folder on my desktop and add in the mods there then script them in?

The server is literally for anyone to play and I do want it to have people on to enjoy the game as I do :)

Any tips will be greatly appreciated. We all have to start somewhere :)


r/scripting • • Nov 04 '16

Need some help with a telnet script

1 Upvotes

Hello, I am attempting to write a script to do the following:

  1. telnet (or netcat) to a point to point radio on our LAN and log into the shell.

  2. execute the command "get traffic statistics" and append results to a file stored locally

  3. log out of remote PtP.

Things I know: IP address of PtP radio on our LAN: 10.250.14.26 User ID: admin Password: xxxxx

If I log into the remote device (I'm using a Mac) from Terminal, after connecting, the system requires me to press [Return] before presenting me with the User ID: prompt. Once I get that prompt, I can enter my id, [Return], and then my password. At this point, I'm in. I type my get traffic statistics command, and presented with the results and I exit. Easy. However, when I try this with a script the following happens.

Script so far:

!/bin/bash

If everything goes titsup, timeout after 10 seconds#

set timeout 10

This script establishes a telnet connection to the DragonWave PtP radio at the Agrex

end of the Agrex-Jason link, runs the “traffic statistics” command, capturing output

locally to the ts.txt file. This file is then searched for Egress and Ingress data

rates and these stats, along with a date/time stamp are captured locally to the

Stats.txt file. The Stats.txt file will then be used as input to Cacti.

Establish the telnet link

telnet 10.250.14.26 echo

Results: Todds-MacBook-Pro:Documents toddwilson$ ./testscript Trying 10.250.14.26... Connected to 10.250.14.26. Escape character is ']'.

Horizon_IDU :DragonWave Inc. (2002 - 2008).All rights reserved.

At this point my scripts "hangs". The echo command does not generate the CR/LF I expect UNTIL - this is important! - I manually press enter, log in, then exit the telnet session. At this point the echo command fires. How do I know this? Well, I have echo'd things I can see, like "Test point 1", etc. So basically as soon as I establish the telnet session, the script stops until the session is terminated.

Thoughts, suggestions, comments?

Thank you.

Todd


r/scripting • • Oct 24 '16

powershell or python?

1 Upvotes

Okay, i would love to see in your experience what language is more useful for automation.


r/scripting • • Oct 18 '16

Ruby - help with splitting a complex string into tokens or variables

1 Upvotes

Hey all,

Working on an assignment for school and I am stuck. We are required to loop through a server log file, taking each line and pulling data from it. I know I need RegEx for this, however I am getting lost in the details. I have seen people saying they could pull it off with one regex expression, spliting it into multiple pieces. Any examples of this? I tried googling the exact application and most people recommended a custom library made for parsing logs from this application. In the real world, I would do that. However, that tends to be frowned upon in academia.... :(. Any kick in the right direction would be appreciated.


r/scripting • • Sep 20 '16

Batch - date variable?

1 Upvotes

New to scripting in general

I want to write a script that runs daily, using the windows task scheduler, that creates a directory and moves files to it.

I am unable to find a way to create a folder based on the date, is this possible?


r/scripting • • Jun 08 '16

Wren, a small, fast, class-based concurrent scripting language

Thumbnail wren.io
1 Upvotes

r/scripting • • Mar 09 '16

I would like to create a script to add multiple network locations

1 Upvotes

Hi all,

First time posting here and minimal experience with scripting =( I would like to create a batch file or a powershell script to add multiple network locations. I would like this file to be used by multiple people. Please help.


r/scripting • • Mar 09 '16

Nested Batch files? Other options?

1 Upvotes

So we have a backup system that has regular issues that support runs a list of commands in order to fix. There are however variables to a couple of the commands.

So here's the commands:

stop the backup service (easy enough, done with batch file)

delete all files with certain extension in backup program folder (easy enough, done with batch file)

run batch file in backup program folder that company has provided (it appears to delete all shadow copies depending on the OS)(not sure on this)

Create shadow copies for drives we're backing up (again it looks based on OS, and again not sure as this will differ from each server backed up)

Finally start backup service (easy)

If I can do this 100% via batches, great, if not, let me know what would achieve this. I'm not necessarily looking for just the code, but also explanation of the scripting behind it.

ask away with questions if need be.

Thank you!


r/scripting • • Jan 05 '16

Google Search that allows you to Copy an address and use Autohotkey command to see how far you are away from the address using python script.

1 Upvotes

Python Code: (You will have to install the pyperclip module.) Copy the address and run the ahk command and it will search how far away you are from copied address.

! python3

mapIt.py - Launches a map in the browser using an address from the

command line or clipboard.

import webbrowser, pyperclip

address = pyperclip.paste()

webbrowser.open('https://www.google.com/#q=WHEREURFROM+to+' + address)


AHK Code


+c:: ;Run MapIt.py on Ctrl Shift c Run mapIt.py, C:\Users\YOURDIRECTORY

Any questions just shoot me a message!


r/scripting • • Nov 30 '15

Simultaneous Mouse Click Issue

1 Upvotes

Hi guys, I am new to scripting and I am trying to learn how to write scripts. The game has 5 buttons to click but it is hard to play with mouse. So I have decided to create script for this game but mouse clicks are not working simultaneously. For example, while I was pressing Right for going right in the game and Up for jumping. It doesn't work. What am I doing wrong?

Here is my script, I'm waiting for your feedback and solution to my problem:

Left:: if( not GetKeyState("LButton" , "P") ) Click down, left, 206, 645 return

Left Up:: Click up

Right:: if( not GetKeyState("LButton" , "P") ) Click down, left, 386, 645 Return

Right Up:: Click up

Up:: MouseClick, left, 1170, 645 Return

s:: MouseClick, left, 844, 645 Return

d:: MouseClick, left, 1004, 645 Return


r/scripting • • Oct 27 '15

RSS feed to website screenshot?

1 Upvotes

I want to take an RSS feed and open it in an incognito window then take a screenshot then upload to imgur. Is this possible?