+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
Scripts Thread, Need Script to take user input add | signs in certain places and save as a text file in Coding and Web Development; I just got a nice job after I got out of the military but I really need to make myself ...
  1. #1

    Join Date
    Sep 2013
    Posts
    10
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Need Script to take user input add | signs in certain places and save as a text file

    I just got a nice job after I got out of the military but I really need to make myself more useful so that they will decide to keep me. I've been working very hard to make the best impression here so this would really help in making me stand out. If you help me with that script it will help me so much. This script would simplify the work I do and take a job that takes 10 minutes to do per job and condense it to a matter of seconds. Here is what I need. I need to create a text file that takes user input and separates each word provided and separates them by a | or a series of pipes. I need the script to ask the user for the new hire's login, the new hires name, the cost center, the vendor, the manager, the date of birth, and "is there another new hire;" which would then prompt the script to run through the questions again to provide a second line of out put and a third etc etc. until the user ansers "no" to the new hire question. Now, the output from each series of the 6 questions needs to contain the users input plus the pipes with a few special additions to the output.
    Basically, in out organization we assign a user ID that is a letter and then a number which may have the letter A at the end. That will be provided by the user in the first question,

    First question: "What is the new hires login?" the script will take that login name for the first question and the text it will add first to the line of output will look like this:

    N55555A|55555A
    *Notice that here the new hire's login is generated twice but the second time the first letter is not present. This must be this way for future reporting and auditing. If another question asking for the last 6 of the user's login needs to be added to create this line that will work.

    The second question, "What is the new hires first and last name?" It will take that in put and add the | signs in the following manner:

    N55555A|55555A|Jon|Doe

    The next question: "What is the new hire's cost center?" That input will be added to the line with the pipes like so:

    N55555A|55555A|Jon|Doe|||||||||||||55555

    The next question: "What is the new hire's vendor company name?" That input will add to the output line as follows:

    N55555A|55555A|Jon|Doe|||||||||||||55555||Personne l Consulting LLC

    The next question: "What is the new hire's location code?" That input will add to the output:

    N55555A|55555A|Jon|Doe|||||||||||||55555||Personne l Consulting LLC|Headquarters||||||||||||||

    The next question: "What is the hiring manager's user ID?" That input will add to the line with the pipes as follows:

    N55555A|55555A|Jon|Doe|||||||||||||55555||Personne l Consulting LLC|Headquarters||||||||||||||U451492|451492
    *Notice that here the manager's login is generated twice but the second time the first letter is not present. This must also be this way for reporting. If another question asking for the last 6 of the user's login needs to be added to create this line that will be fine.



    The next question: "What is the last 6 of the new hire's ssn or what is 2 digit month, 2 digit day, and first and last initial in capital letters?" In some situations the new hire may not have an ssn so the date of birth needs provided. Either way that input needs to be added at the end of the line of text as follows:

    N55555A|55555A|Jon|Doe|||||||||||||55555||Personne l Consulting LLC|Headquarters||||||||||||||U555555|555555||||03 04JD

    The next question the answer will not be recorded in the text file that will be generated at the end. "Is there another new hire?"

    The answer to the above question will either prompt the script to run through the questions again to create an additional line of data for an additional new hire or it will prompt the script to save the line of text created by the script to a text file on the user's desktop and close. If the answer to the next question is Yes it will save the additional line of data underneath the first line like so:

    N55555A|55555A|Jon|Doe|||||||||||||55555||Personne l Consulting LLC|Headquarters||||||||||||||U555555|555555||||03 04JD
    N55556A|55556A|Jane|Doe|||||||||||||55555||Personn el Consulting LLC|Headquarters||||||||||||||U555555|555555||||02 03JD

    I need this script to create the above text based on the questions into a text file so I can copy that text and paste it into another program. I would appreciate the help so much as it would help me keep my job in this economy. Thank you very much for any help.
    Last edited by techadmin32; 7th September 2013 at 06:27 PM.

  2. #2
    MordyT's Avatar
    Join Date
    Sep 2012
    Location
    In a computer
    Posts
    433
    Thank Post
    43
    Thanked 69 Times in 64 Posts
    Rep Power
    19
    I'd be willing to work on something here for you... Just won't be finished overnight.

    When do you need it by? Please don't say asap...

  3. #3

    Join Date
    Sep 2013
    Posts
    10
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    thanks for responding! no theres no hurry. its not a task I was given or anything. it would just be something really cool I could bring to the table that would make a lasting impact. I want to make an impression by taking something that I think could be automated and it needs to be done daily so it would be a tremendous time saver. I'm taking responsibility for something to ease the workload so what better way to do it then with this script. there is a heavy workload; which is good, lol. job employment. but ya, I'm wasnt asked to do it and its just a secret project I'm working on so once its all set I can present it to the table. Thanks again! it would be so awesome.
    Last edited by techadmin32; 8th September 2013 at 04:51 AM.

  4. #4
    MordyT's Avatar
    Join Date
    Sep 2012
    Location
    In a computer
    Posts
    433
    Thank Post
    43
    Thanked 69 Times in 64 Posts
    Rep Power
    19
    Quote Originally Posted by techadmin32 View Post
    I just got a nice job after I got out of the military but I really need to make myself more useful so that they will decide to keep me. I've been working very hard to make the best impression here so this would really help in making me stand out. If you help me with that script it will help me so much. This script would simplify the work I do and take a job that takes 10 minutes to do per job and condense it to a matter of seconds. Here is what I need. I need to create a text file that takes user input and separates each word provided and separates them by a | or a series of pipes. I need the script to ask the user for the new hire's login, the new hires name, the cost center, the vendor, the manager, the date of birth, and "is there another new hire;" which would then prompt the script to run through the questions again to provide a second line of out put and a third etc etc. until the user ansers "no" to the new hire question. Now, the output from each series of the 6 questions needs to contain the users input plus the pipes with a few special additions to the output.
    Basically, in out organization we assign a user ID that is a letter and then a number which may have the letter A at the end. That will be provided by the user in the first question,

    First question: "What is the new hires login?" the script will take that login name for the first question and the text it will add first to the line of output will look like this:

    N55555A|55555A
    *Notice that here the new hire's login is generated twice but the second time the first letter is not present. This must be this way for future reporting and auditing. If another question asking for the last 6 of the user's login needs to be added to create this line that will work.

    The second question, "What is the new hires first and last name?" It will take that in put and add the | signs in the following manner:

    N55555A|55555A|Jon|Doe

    The next question: "What is the new hire's cost center?" That input will be added to the line with the pipes like so:

    N55555A|55555A|Jon|Doe|||||||||||||55555

    The next question: "What is the new hire's vendor company name?" That input will add to the output line as follows:

    N55555A|55555A|Jon|Doe|||||||||||||55555||Personne l Consulting LLC

    The next question: "What is the new hire's location code?" That input will add to the output:

    N55555A|55555A|Jon|Doe|||||||||||||55555||Personne l Consulting LLC|Headquarters||||||||||||||

    The next question: "What is the hiring manager's user ID?" That input will add to the line with the pipes as follows:

    N55555A|55555A|Jon|Doe|||||||||||||55555||Personne l Consulting LLC|Headquarters||||||||||||||U451492|451492
    *Notice that here the manager's login is generated twice but the second time the first letter is not present. This must also be this way for reporting. If another question asking for the last 6 of the user's login needs to be added to create this line that will be fine.



    The next question: "What is the last 6 of the new hire's ssn or what is 2 digit month, 2 digit day, and first and last initial in capital letters?" In some situations the new hire may not have an ssn so the date of birth needs provided. Either way that input needs to be added at the end of the line of text as follows:

    N55555A|55555A|Jon|Doe|||||||||||||55555||Personne l Consulting LLC|Headquarters||||||||||||||U555555|555555||||03 04JD

    The next question the answer will not be recorded in the text file that will be generated at the end. "Is there another new hire?"

    The answer to the above question will either prompt the script to run through the questions again to create an additional line of data for an additional new hire or it will prompt the script to save the line of text created by the script to a text file on the user's desktop and close. If the answer to the next question is Yes it will save the additional line of data underneath the first line like so:

    N55555A|55555A|Jon|Doe|||||||||||||55555||Personne l Consulting LLC|Headquarters||||||||||||||U555555|555555||||03 04JD
    N55556A|55556A|Jane|Doe|||||||||||||55555||Personn el Consulting LLC|Headquarters||||||||||||||U555555|555555||||02 03JD

    I need this script to create the above text based on the questions into a text file so I can copy that text and paste it into another program. I would appreciate the help so much as it would help me keep my job in this economy. Thank you very much for any help.
    I finished it... was able to reuse most of my code for a similar project.
    V1.0 is uploaded at http://mordyt.com/edu/NewHire.exe
    The first time it runs, it will give you a PC hash that you will need to send back to me, I will generate a license file for your use. (You can ignore the name/e-mail part, all I need is the hash)
    Test it out, let me know your feedback.

    Last edited by MordyT; 8th September 2013 at 06:55 AM.

  5. 2 Thanks to MordyT:

    Dos_Box (8th September 2013), techadmin32 (8th September 2013)

  6. #5

    Join Date
    Apr 2010
    Posts
    2,036
    Thank Post
    83
    Thanked 187 Times in 154 Posts
    Rep Power
    83
    Google forms has this all built in I think and is free and ready to go.

    https://support.google.com/drive/answer/87809?hl=en

  7. #6

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,343
    Thank Post
    624
    Thanked 1,584 Times in 1,421 Posts
    Rep Power
    414
    Is the last 6 of the new hire's and managers logins automatically populated? if not it should be.

    Ben

  8. #7
    MordyT's Avatar
    Join Date
    Sep 2012
    Location
    In a computer
    Posts
    433
    Thank Post
    43
    Thanked 69 Times in 64 Posts
    Rep Power
    19
    Quote Originally Posted by plexer View Post
    Is the last 6 of the new hire's and managers logins automatically populated? if not it should be.

    Ben
    It will be in the next version. Just waiting on feedback to see what else may be needed.

  9. #8

    Join Date
    Sep 2013
    Posts
    10
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    It works great. I really like it so hopefully we will be able to use it. I know they have a software approval process and I think it would be awesome. The only thing that I think might be a road block is its too advanced for what my boss thinks. its hard to change old dogs, ya kno? If it was a little simpler like a vbs script that we could edit because there are other signs other than the | sign that we use and I could play with the script with other situations because ascript that does this would be very versatile. I think so many people could use it in data entry jobs. this is the first IT job ive had that has a data entry feel to it. its an infosec position and to me it reminds me of HR work. im used to AD admin type work.

  10. #9

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,343
    Thank Post
    624
    Thanked 1,584 Times in 1,421 Posts
    Rep Power
    414
    Here's a vbscript that will do it

    Code:
    'New Hire script plexer 08/09/2013
    Option Explicit
    dim h_login, h_login2, h_forename, h_surname, h_ccentre, h_vendor, h_loc, h_manid, h_manid2, h_ssn, x, strfile, objFSO, objFile
    
    strFile = "c:\path_to_file_here\test.txt"
    
    Sub GetInput()
    Do While X = 0
        h_login = InputBox ("Please enter login","Step 1")
        If h_login = "" Then
            Wscript.Echo "You must enter a login."
        Else
    	h_login2 = right(h_login,len(h_login)-1)
            Exit Do
        End If
    Loop
    
    Do While X = 0
        h_forename = InputBox ("Please enter forename","Step 2")
        If h_forename = "" Then
            Wscript.Echo "You must enter a forename."
        Else
            Exit Do
        End If
    Loop
    
    Do While X = 0
        h_surname = InputBox ("Please enter surname","Step 3")
        If h_surname = "" Then
            Wscript.Echo "You must enter a surname."
        Else
            Exit Do
        End If
    Loop
    
    Do While X = 0
        h_ccentre = InputBox ("Please enter a cost centre","Step 4")
        If h_ccentre = "" Then
            Wscript.Echo "You must enter a cost centre."
        Else
            Exit Do
        End If
    Loop
    
    Do While X = 0
        h_vendor = InputBox ("Please enter vendor details","Step 5")
        If h_vendor = "" Then
            Wscript.Echo "You must enter vendor details."
        Else
            Exit Do
        End If
    Loop
    
    Do While X = 0
        h_loc = InputBox ("Please enter location","Step 6")
        If h_loc = "" Then
            Wscript.Echo "You must enter a location."
        Else
            Exit Do
        End If
    Loop
    
    Do While X = 0
        h_manid = InputBox ("Please enter managers ID","Step 7")
        If h_manid = "" Then
            Wscript.Echo "You must enter managers ID."
        Else
    	h_manid2 = right(h_manid,len(h_manid)-1)
            Exit Do
        End If
    Loop
    
    Do While X = 0
        h_ssn = InputBox ("Please enter SSN","Step 8")
        If h_ssn = "" or len(h_ssn) <> 6 Then
            Wscript.Echo "SSN not entered or not 6 characters."
        Else
            Exit Do
        End If
    Loop
    End Sub
    
    Call GetInput
    
    set objFSO = CreateObject("Scripting.FileSystemObject")
    set objFile = objFSO.OpenTextFile(strFile, 8, True)
    
    objFile.WriteLine(h_login & "|" & h_login2 & "|" & h_forename & "|" & h_surname & "|||||||||||||" & h_ccentre & "||" &  h_vendor & "|" & h_loc & "||||||||||||||" & h_manid & "|" & h_manid2 & "||||" & h_ssn)
    
    objFile.Close
    Doesn't loop back to the beginning automatically atm but you can just re-run it and it appends to the file you set at the top.

    Ben
    Attached Files Attached Files
    Last edited by plexer; 8th September 2013 at 06:55 PM.

  11. Thanks to plexer from:

    techadmin32 (8th September 2013)

  12. #10

    Join Date
    Sep 2013
    Posts
    10
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I tried to run it and i think line 2 had an extra comma and then I went to run it again. Now, im working on line 89. Its the one where it adds in the pipes. For some reason it doesnt like that line. I'm really getting more interest in vb these days. If you know a good book I'll get a copy and check it out. At the end of line 2 I got an expected identifier error and it looked like after objfso, was making the script expect another identifier? lol, so i deleted the comma. i really have no idea i was just guessing but line 89's got me.

  13. #11
    MordyT's Avatar
    Join Date
    Sep 2012
    Location
    In a computer
    Posts
    433
    Thank Post
    43
    Thanked 69 Times in 64 Posts
    Rep Power
    19
    Well, if you decide to go with mine, a new version is at http://MordyT.com/edu/NewHire1.exe that doesn't ask for the last 6 of the ids... It grabs from the first input.
    Edit:screenshot added:
    Last edited by MordyT; 8th September 2013 at 07:50 PM.

  14. Thanks to MordyT from:

    techadmin32 (8th September 2013)

  15. #12

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,343
    Thank Post
    624
    Thanked 1,584 Times in 1,421 Posts
    Rep Power
    414
    Attached vbs to post.

    Ben

  16. Thanks to plexer from:

    techadmin32 (8th September 2013)

  17. #13

    Join Date
    Sep 2013
    Posts
    10
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Both your responses are outstanding and I'm going to bring up both of them. The vbscript gave me a permission denied after i went through it. I don't it would act like I cant save to my own desktop. I think thats what might be causing it, a permissions issue maybe? I'm I really love Mordy's exe but my boss has his way of doing things and it might be too much legwork for him because he'd have to approve it. It would be useful to all our home workers so I am still going to let him check it out. Home users use their home PC so this is great for them no matter what. At the corporate office where things are stricter that VBscript is perfect because its easier for us to use without the hassle of getting other managers to approve it. Home users though will definitely appreciate the exe without a doubt so both of them will be used. Thanks so much really. I just signed up for the website and I am really impressed. Great resource!

  18. #14

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,343
    Thank Post
    624
    Thanked 1,584 Times in 1,421 Posts
    Rep Power
    414
    Sounds likely to be permissions for where you're saving the file.

    Ben

  19. #15

    Join Date
    Sep 2013
    Posts
    10
    Thank Post
    6
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    It says the errors in line 86 char 1. I don't see the error? it looks like it makes sense to me. I'm on my home machine and I'm logged in with the admin account. I cant see any thing that looks out of place. I'm thinking if I'm looking at the right line its trying to save it. I cant get it to the part where it saves the file so I can't see if the vbscript works as far as generating the input in the form of a text file with the pipes.


    I edited this line like so

    strFile = "c:\Users\username\Desktop\NewHireImports.txt"

    Thanks for the help Ben and MordyT!
    Last edited by techadmin32; 8th September 2013 at 09:18 PM.

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Script to track user logins
    By Gatt in forum Scripts
    Replies: 47
    Last Post: 2nd August 2013, 10:44 AM
  2. need a script to take a DIR list to XLSX
    By Mr_J in forum Scripts
    Replies: 17
    Last Post: 12th July 2013, 04:13 PM
  3. Script to remove users from one group and add to another
    By JMBates in forum Windows Server 2000/2003
    Replies: 5
    Last Post: 11th April 2012, 10:02 AM
  4. Replies: 5
    Last Post: 11th April 2012, 10:02 AM
  5. Script to change user email in AD (or Exchange)
    By SpuffMonkey in forum Scripts
    Replies: 16
    Last Post: 8th November 2005, 10:31 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •