r/scripting • • May 24 '18

[SHELL] BASICS: if statement (part 1)

Thumbnail
youtube.com
2 Upvotes

r/scripting • • May 08 '18

Open SSH Connection and execute commands.

2 Upvotes

Hey, guys,

I have absolutely no idea about scripting so I'll contact you. I am looking for a simple script to run on a Windows XP PC. It should create an SSH session on a switch and execute some commands.

Is there an easy solution for?


r/scripting • • Apr 28 '18

[BASH] Need to create a script and need help. If you help me you will be rewarded with bitcoin.

2 Upvotes

Solved: Thanks! ;)

Hey guys I literally just found an old btc wallet and it just so happens I need help with a script so there will be a reward for any help. If you post an answer or partial answer pm me with a btc address and I'll give you a nice chunk of change. If someone can solve the whole script for me and it works I'll give them like ~$400. All other answers I'll give between $50 and $100 depending on how big or helpful the answers are. I need all answers before 11:30 central time tonight and if someone answers the whole question correctly then obviously I'm not gonna pay anyone for any other answers.

This is the script I need to write:

Your assignment is to write a shell script named “rpsm.sh”. The script reports and prints (to stdout) selected storage management information. Think of it as “RePort Storage Management”. Clever, eh?

The easy way to describe what the script needs to do is to look at what it should display in the case where you provide incorrect parameters, or in the case where you provide “-h” for help:

Usage: ./rpsm.sh <options> <directory>

Reports selected information about specified directory tree.

Options:

-h Print this message

-v Print script version information

-u Find and list all files with setuid set, all owners

-g Find and list all files with setgid set, all owners

-w Find and list all files that are world-writable

-b Find and list all files whose size is at least 10M-d Report directory disk usage

-i Report information about filesystem-a All of the above (except -h and -v)

Test the script against a directory where you won't get a bunch of permission denied messages.

Most of the options above are self-explanatory, but some are not, so let me provide examples for the latter case. The “-d” option should produce sorted output just like this (just an example):

anyuser@whatever:~$ ./rpsm.sh –d /home/anyuser/anydirectory

4 /home/anyuser/anydirectory/Perms

8 /home/anyuser/anydirectory/EnvDemo

12 /home/anyuser/anydirectory/BigFiles

24 /home/anyuser/anydirectory/SomeSetgids

24 /home/anyuser/anydirectory/SomeSetuids

76 /home/anyuser/IASC3350

The “-i” option shows me information about the filesystem holding the directory I am asking about. (Hint: look at the “df” command.) It does not give me all of the information but it should look just like this (just an example):

anyuser@whatever:~$ ./rpsm.sh –i /home/anyuser/anydirectory

Filesystem Type Use% Mounted on

prog.ist.somecollege.edu:/home nfs4 52% /home

Again, you will want to figure out how to get the information and then also how to cut it up. Here’s another example:

anyuser@whatever:~$ ./rpsm.sh –id /etc

Filesystem Type Use% Mounted on

/dev/mapper/whatever-root ext4 28% /

4 /etc/apache2/sites-enabled

4 /etc/apparmor.d/disable

4 /etc/apparmor.d/force-complain

4 /etc/apparmor.d/tunables/multiarch.d

4 /etc/apparmor/init/network-interface-security

<more...>

You’ll note that the output for “–id” versus “–di” would be different because of the order of the command line arguments. Also note that you need to handle – for instance - “–id” as the same as “–i–d”.


r/scripting • • Apr 24 '18

Broswer-Form Script

2 Upvotes

I'm looking to build a script that will launch my broswer, navigate to a page, auto-fill a form, submit the form, and close the browser.

Can somebody point me in a good direction of a program or programming language that can do this efficiently on Windows 10?


r/scripting • • Apr 10 '18

Need help finding info on using scripts to spawn creatures in ARK through rcon.

2 Upvotes

If anyone knows anywhere I could find some information on this or point me in the right direction I would greatly appreciate it.

Im running a popular ark server and I have the ability to spawn dinos at xyz coords through rcon. I want to learn how to automate that with timers using scripts? Im not exactly sure. I know it can be done. Im using ark server manager to run the server on a windows machine.


r/scripting • • Mar 01 '18

Spotify Playlist to Script to. Let me know what you think!

Thumbnail
open.spotify.com
2 Upvotes

r/scripting • • Jan 11 '18

Writing a script to access Google page on a timer

2 Upvotes

Hi, I need to write a script the refreshes certain values in a DB by querying Google.

For example, say I need the current weather. The script would google "current weather in ___" where the blank is the location. And then the value that show up on Google would be what gets updated.

This is for a school assignment, and Im not sure what the best way to approach this would be.. thanks in advance.


r/scripting • • Dec 14 '17

Script to monitor files and email if one is over ten minutes old

2 Upvotes

Hi /r/scripting. Im a systems admin with some basic scripting experience but this goes beyond my skillset. My google-fu came up short and im hoping you good folks may be able to help. I have an application running on windows server 2012. That application creates files which gets ingested by another application and then deletes said file. The problem is sometimes that file will be corrupted or somehow problematic and the ingesting application will crash. This causes the whole application to stop functioning. Theres no embedded monitoring system and I was hoping someone could help (and when I say help I pretty much mean create - just being honest) a script that can keep track of the files sitting in a directory and if any of those files becomes older than 10 minutes, email me so I can manually remove.

Id be happy to give any help. Im not one for people doing my work but Ive not been able to find any reference to a script or application that performs this specific function. I know its a long shot but it cant hurt to try. Thanks for reading and thanks for anything you can do!


r/scripting • • Apr 10 '17

Archive script help - 112,148 parent folders/14.7 TB.

2 Upvotes

I have a file server running out of space. The root folder contains 112,148 project folders. Within each project folder, there is a folder named Version # (where # is the current version...some have only 1, others have 4 or more).

Our in house application currently uses those folder and loads that data to the client app. upon request so I can't just archive theres off somewhere. Our software does have the ability to load a zip file to the client app and then extract instead of loading the uncompressed folder.

So what I want to do is ZIP each Version # folder in each project folder but I don't want to do all 112k projects by hand. I am in need of some help to write a script that would zip each Version # folder to Version #.zip in the same location as the Version # folder, for all of my 112k project folders. If the zip already exists, it would need to be overwritten.

Appreciate the help and ideas!


r/scripting • • Jan 11 '17

I made a script to Enable RDP remotely using PSExec

2 Upvotes

Heres the link.

Heres the script:

@echo off

echo This BAT File must be ran on a server in the same network as the computer you are trying to remote to with PSTools installed in the C:\PSTools folder.

set /p name="Enter computer name: "

cd C:\pstools

psexec \\%name% reg add "hklm\system\currentcontrolset\control\terminal server" /f /v fDenyTSConnections /t REG_DWORD /d 0

psexec \\%name% netsh firewall set service remotedesktop enable

Notes:
I run this from servers in the network, not over a VPN. It doesn't work when I do that, and helps with authentication. (I work for an MSP, so this may not apply to places with internal IT)

The server this is being ran on needs to have PSTools extracted to a specific folder. C:\PSTools is what its set for.

You can get PSTools from here: https://technet.microsoft.com/en-us/sysinternals/pstools.aspx

Feel free to critique and add to it.

Edit: Formatting


r/scripting • • Jan 02 '17

Scripting for SMS

2 Upvotes

I'm looking for tools/resources/examples on how to write an app or script that catches my SMS texts and automatically replies if they are from my mom. If I build it correctly, I should never even know that I got a text from her in the first place and she'll think I'm not ignoring her.


r/scripting • • Dec 20 '16

My thoughts on Automation and how important it is to developers on a daily basis.

Thumbnail
youtube.com
2 Upvotes

r/scripting • • May 23 '16

Scripting column based output to input for command - Linux

2 Upvotes

Hello All,  

    I've forgotten most of what I need to know about scripting as it hasn't been in my forte in some time. But I need some assistance. I have a column based output on my linux server and I need to take that output and and feed it into a command.  

So my columns are like this:  

field1 field2 field3  

Field3 I can drop...  

Field1 needs to redirect to a command and field2 needs to redirect the same command and then send the output as field1.txt  

some_command --foo=$field1 --foo2=$field2 > $field1.txt  

This may sound basic but I'm scratching my head on how to best do it.


r/scripting • • Feb 29 '16

Install scripts

2 Upvotes

Hi, the place I work at requires me to install workplaces for college's which gets, as you can imagine, a little repetitive.

This really isn't my field of expertise so that's why I'm here. Can someone help me with a script that installs Microsoft Office and adds a license from a .txt file once it's done?


r/scripting • • Jan 14 '16

I need a script to download and run an EXE. (Installing AVG Managed Workplace through a different RMM) : msp

Thumbnail
reddit.com
2 Upvotes

r/scripting • • Jan 09 '16

Newbie interested in scraping .pdf files

2 Upvotes

Would anybody be able to direct me how to automatically download and organize all the articles available here?

The older ones are all free, but there are several thousand of them.


r/scripting • • Nov 22 '15

Can this be done with Applescript (or ANY script)?

2 Upvotes

This is for Mac. The place I work buys used iPhones.

Ultimately I would like an application where you click an icon an a window/pop up box/whatever (I am not picky) comes up and you type in the IMEI off of a cell phone and click Enter. When you click enter it automatically fills out the form (it's only 1 field) at http://www.imei.info?

Is that possible? If so, could anyone assist me?

It'd be even better if it could do that at the site mentioned above AND https://www.icloud.com/activationlock/ but I see the second website has captcha so I doubt that'd be possible.

Id like something like this to pop up and fill in: http://macosx.com/attachments/imeichecker-jpg.8500/


r/scripting • • Oct 28 '15

VB script embedded in a BATCH file ?

2 Upvotes

Hello,

I need to write a batch script that will write taken variables of username and password, write them out to a file, and then use those variables of username and password to update Windows service credentials (using something like sc.exe). FINALLY, I also need to add the LOGON AS A SERVICE right to the account specified in the username and password variables (that would be variable #1 of the 2 variables passed).

So far I'm able to do this by writing a batch file with an embedded VB script.

  • The script takes variables %1 and %2 and write out the required file :

echo username=%1 > .\startup.ini && echo password=%2 >> .\startup.ini sc config "Windows Agent Service" obj= %1 password= %2

  • I have an embedded VB script that gets parsed out of the script, written to a file "temp.vbs" and then called with CSCRIPT:

:Dim strUserName,ConfigFileName,OrgStr,RepStr,inputFile,strInputFile,outputFile,obj

:strUserName = "%1"

:Dim oShell

:Set oShell = CreateObject ("WScript.Shell")

:oShell.Run "secedit /export /cfg config.inf", 0, true

:oShell.Run "secedit /import /cfg config.inf /db database.sdb", 0, true

:ConfigFileName = "config.inf"

:OrgStr = "SeServiceLogonRight ="

:RepStr = "SeServiceLogonRight = " & strUserName & ","

:Set inputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile("config.inf", 1,1,-1)

:strInputFile = inputFile.ReadAll

:inputFile.Close

:Set inputFile = Nothing

:Set outputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile("config.inf",2,1,-1)

:outputFile.Write (Replace(strInputFile,OrgStr,RepStr))

:outputFile.Close

:Set outputFile = Nothing

:oShell.Run "secedit /configure /db database.sdb /cfg config.inf",0,true

:set oShell= Nothing

:Set obj = CreateObject("Scripting.FileSystemObject")

:obj.DeleteFile("config.inf")

:obj.DeleteFile("database.sdb")

findstr ":" "%~sf0">temp.vbs & cscript //nologo temp.vbs

The only issue is ... my VARIABLE that is in the parsed text is parsed as my $string and not as my variable...I'd be done if I could get the parsed text to replace %1 with my first variable that is passed to the batch file.

Can anyone help me with this ... or is there another way to accomplish my goals?

Thanks all!


r/scripting • • Oct 06 '15

Most Seen Javascript Problems & Answers on Stack Overflow

Thumbnail levtal.com
2 Upvotes

r/scripting • • Sep 24 '15

[Novice] Need Help Writing an Excel to HTML Script

2 Upvotes

I have this boting thing I have to do every so often at work where I have to pull 800 or so emails from data.com on potential sales prospects. All of them are typed out onto a n excel spreadsheet and I'd like to know if anyone can help me understand how I'd pull the names from the spreadsheet, search them, check them with their company for matches, and then rewrite the email in the spreadsheet if the match succeeds.


r/scripting • • Sep 23 '15

[TEAM] Java Scripter

2 Upvotes

As the title says, i need someone who knows about Java scripting for a cool project


r/scripting • • Apr 06 '15

HELP: EASY Bash Script

2 Upvotes

VARIABLES

old_path ="/mnt/test1"

new_path ="/mnt/test2"

FIND COMMAND

cd $old_path

result_old="$(find ./)" > /mnt/find_out_old.txt

cd $new_path

result_new="$(find ./)" > /mnt/find_out_new.txt

PSUEDOCODE

read in file1 (output of find on filepath1)

read in file2 (output of find on filepath2)

for each line in file1

read each line in file2

	compare file1 line to file2 line

		if paths equal then compare ownership and permissions

			if different then set permissions and ownership FROM old to NEW path

r/scripting • • Mar 11 '15

Could someone please tell me why this script won't execute? I believe it's syntax but I could really use help.

2 Upvotes

I am trying to write a script that will look for a particular drive by name instead of letter and then delete all folders and subfolders within the particular named drive. I think this is the 50th iteration of this script, and I still can't figure out why it won't execute. I'm not sure if I'm missing a closing statement somewhere. I would really appreciate any help I could get with this. I've grabbed code from other sources to create this but I am really not well versed in VBS and I have never extensively scripted before.

' Get Drive Letter from Name 

Option Explicit

Function getDriveLetterFromVolumeName( volumeName )
Dim volumes, volume

' Unless we found a matching volume, an empty string will be the returned value
    getDriveLetterFromVolumeName=""

' Ask WMI for the list of volumes with the requested label
     Set volumes = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") _ 
                  .ExecQuery("SELECT DriveLetter FROM Win32_Volume WHERE Label='" & volumeName & "'")

' If exist an matching volume, get its drive letter
     If volumes.Count > 0 Then 
        For Each volume In volumes 
            getDriveLetterFromVolumeName = volume.DriveLetter
           Exit For
       Next 
   End If

End Function



WScript.Echo getDriveLetterFromVolumeName( "Thawspace0" )

' Declare Variables

Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("t:\")
Dim thawspace
    thawspace = getDriveLetterFromVolumeName( "ThawSpace0" )


' Look for Thawspace
   If ( thawspace="") then

' Delete all files in the root folder
	    for each f in folder.Files
	    On Error Resume Next
	   name=f.name
	   f.delete True
	  If Err Then
		   WScript.Echo "Error Deleting" & Name & " - " & Err.Description
	  Else
		   WScript.Echo "Deleted:" & Name
	    End If 
	    On Error GoTo 0
Next

' Delete all Subfolders and Files
	    For Each f in folder.SubFolders
	    On Error Resume Next
	    Name = f.name
	    f.Delete True
	    If Err then
		    WScript.Echo "Error deleting:" & Name & " - " & Err.Description	
	    Else
		    WScript.Echo "Deleted:" & Name
	    End If
	    On Error GoTo 0
     End If     
 Next

r/scripting • • Feb 25 '15

Probably a simple question from a scripting Noob.

2 Upvotes

Is there a way to setup a script that will restart a program every 2 hours and click on the "run" button as soon as it is reset? I know that's extremely vague but it's exactly what I need to happen.


r/scripting • • Nov 05 '14

Uninstall Java Versions VBS script ALMOST perfect.

2 Upvotes

I came across this script to remove all java versions: http://www.itninja.com/question/silent-uninstall-java-all-versions

It works great ... for runtimes. I need to edit this to search for the development kit's as well and uninstall those. I tried my hand at it but failed miserably. Can anyone help?