POST and Submit to Google Form using CURL

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome everyone in this session I'll be talking about posting to Google forms using the curl command so there's a command called curl uh for example like this curl uh I will be using this to post to a Google form that I'm going to create here for you guys from so this is going to be from start to finish uh why do I need this or why did I need to do this I need to get the IP information for one of the computers that I had uh remotely without me actually being logging into it so I'll be creating a task manager schedule task for it so the script runs every few minutes to get the current IP address because the IP address might change it's a local internal IP address like if you have a bunch of virtual machines for example you don't know which virtual machine it belongs to you want to write something so it can post automatically to an online portal so I tried using SharePoint to do a curl command to post to it but I was getting stuck with a bunch of errors and whatnot so I stumbled upon Google forms I was like you know what Google forms might be able to do it better or might be able to actually do the posting or curl might be able to do posting to a form so here we are so in this video the topic is basically posting to a Google form so basically autoc completing it using uh command prompt so I'll be using command prompt to actually do the posting so hopefully you guys uh uh will be able to find this useful and implement it in your own settings so let's let's get started I'll be doing from start to finish so I'll be creating a form you guys are welcome to skip the video to the next part or what however you like to do it so so initially we'll be setting up the forms so I'll be creating a form and I'll be also talking about the script that I'm showcasing here uh for fetching the computer information the IP information basically and posting it to the form so this is the script that I've created so it's basic information it gets it does the IP information storage and that's what I want to post to my Google form so if I run the script so the script is right here Google cobat I'm going to call it so I'm going to run the command so so you guys know what it actually does so as you can see it gave me the information like today's date the username that's who I'm used logged in as do who am I I'm logged in as hashtag and the IP address of this virtual machine because I'm using virtual machine here is a Windows 10 so this is a Windows 10 base this is the system name so this is the system name Windows 10 PC and the IP address is 37 s so this script you can write however you like your own script I'll give you a copy of this I'll post in the description as well for this script that I created here uh if you guys want to use this in your own instance if you have bunch of virtual machines that are like being restarted getting a new IP for some reason if you're not using DCP reservation or and whatnot so you can have this script running you can go into task scheduler and basically set this task to run every few minutes or every log on so somebody logs on the script runs and you get the information and then it's going to post to it post to Google so you have an online presence basically you can fet this information without having to log into the virtual machine so right now you see it's just basically a script doing this right up and we're going to do the Google form post using this script itself so I'm going to delete this I'm going to delete this file and we're going to start building the Google form and then start building the curl command and and every Windows 10 instance will come with curl this basic it's always there so you don't have to worry about oh do I need to install something it's already provided built in so Windows 10 Windows 11 Heck if you got Windows XP I'm sure it will work there too but I haven't tried it because I don't have it so first step I'm going to create a Google form to fetch the information just a blank form and I'm going to call it get system information and no thank you uh that's it and I'm going to use uh basic text Fields so I'm going to create short answers I'm going to call it system ID so the name of the system or you can call it system name if you want uh next one I'm going to create uh Simple Text one I'm going to call it um what was the other information I was getting I was getting the IP address so actually username or computer that's the computer name the username the user who's logged in so I just logged in as hashtag so I'm going to give it a name username whoever is logged in I'm going to go next add another question I'm going to call it uh let's call it IP address IP info so this will have the IP address uh next we're going to go uh we will time right so time date info and I will do short answer type and that's it that's all I need to do so the form is built uh you're going to click on send and you going to get the link for it so you going to click on the link icon so this is the URL make sure that you have decided what Fields you want ahead of time so you don't have to kind of know go in back in editing and modifying doing this step over and over so and I'm not going to collect the uh the email address so I'm going to say uh do not collect I'm going to copy the URL so I have another tab open in cognito so I'm going to go there paste it and here's the form so I can fill it out so let's let's just do one real quick so YouTube demo 1 username demo 1 IP 10 do whatever dot just numbers there and date uh let's call it what is 2023 D 11- 21 so that's the date and I'm going to do submit and I'm going to go in here I'm going to close that and you can see here I already got response so YouTube demo IP information now we're going to automate this so the form that we have the one that we just filled out we're going to automate it so I can do this through a curl command to do this um you'll need to click on uh so you have the for go back to the setting go back to the settings there make sure that you don't uh have email collection and all that stuff because that kind of puts it in a different shate because then that's a required field and you can't pre-fill it so you can get a notification if you want so somebody submitted a form and then it'll send you a notification and you can basically uh kind of trigger stuff behind the scenes to if you have power automate you can use that as well so s uh three dots top right get pre-filled link so you're under you're on the form so I don't know why it's called Untitled we called it oh there it is it didn't refresh so again so let me let me start again so we have the forms we have the still showing Untitled Let me refresh this to get information you click on the form Google forms let's close that tab and from here yeah sure jeez I never opened that this is my new account or this is my other account and you're going to click on three dots top right uh right here besides your name or icon uh profile profile picture you're going to click on get prefilled link click on that now you're going to fill it out so we're going to say pre so we're going to call this system ID to easily find what you're filling so uh you'll see it in a bit so AP [Music] info time date and I'm going to click on get link it's going to give you a this link right here and you're going to copy the link and I have my notepad open here so let's do this I'm going to paste it here this is the link that you'll get so that's the link I got so you can see it's got view form this an entry and whatnot we're going to now modify it so for example IP so this entry that's why I said you will need this uh so this field basically correlates to close that this field correlates to your form field so we know right which one which field is which it makes your life way easier so we're going to go here since I'm using this script so this is the script that I'm using for the sto itself you can uh do however you want if you have your own script you this is how the variables are kind of passed so we're going to first modify this link so I'm going to actually submitted as such the default one so form response we're going to change the view form you see view form here we're going to replace that with form response will say form response and you're you're going to get rid of this bit so question mark USP and you're going to up to the end percent say and the entry the first field is a system ID if you try to run this it's not going to work it's going to only push only the first field so these system entries you'll have to split them like this I've done in the script here uh you can see- D so that's what we're going to do we're going to split them up into their individual entries so it can run and parse and at the end this is important so we now building the C command so we're going to put that so curl command now it becomes curl you can have the curl command the word curl itself and at the end you'll have D submit and dashd submit and then you're going to that URL at the end make sure there are no extra spaces there you go and now we're going to replace all of these with Dash D so the first one the first one leave it as such we can leave this as system ID the second one onwards that's where you need to change so the second one from the URL in the URL we can replace the and percent entry with Dash space so again space- D equal d space again then quotes entry ID equal to what whatever the value this is the field value that you want to uh push out or push to the form or fill the form so this is what it becomes now so again these will become uh exactly like this format so dashd so space- d space quotes the entry ID value and then the value that you want to pass to this field so we're going to keep doing this for all of these uh we don't have that many so I am not I'm going to pause this going to just go ahead and do this for these D quotes and then close that and that's it so your command is all all built so here here we have the full command so if I were run this command now on a command prompt my form so let's open the form here it's only got one response so far correct so I am going to I go to my my virtual machine or go to my other instance I'm going to paste that and as you can see it will do its thing it did whatever it had to do and if you go back to the form you see two responses so now I just passed system ID this is the one that I just passed user ID or username IP information and you can look at the individual entries so this is the one with the second entry this is the one that we just passed through using the curl command so this was the command I sent so actually I should clear that so you guys can see the command so that's the command that I pushed out or sent so and again that's how you'll that again that's how you'll build the cro command it's simple as that so if I were to now break it down let's let's do this uh let's build the command so I have this script right I want to push the IP information so and I have it open right I believe I do I'm going to put this down here it's the same command so curl this form ID and whatnot right so I got that and for the system ID I know I'm going to use uh system ID is the computer name this is the variable that is already defined here in the script so I'm going do computer name for my username that will be my username right here again this script I'll post this is just a basic information you don't have to sit through this we have already done the bid that we were interested in posting to Google using curl and IP information and this is IP information so this is my IP variable time and date I have is date and time so let's do this with that Dash in between them and that's what my command becomes now so this is the command if I run so I'm going to save this I just save this and I'm going to go see clear that again and I am going to run this so you'll see a file getting created here I'm going to minimize that and there the command we just built we can close that so now I will run this before I do that I'm going to go in here it says two responses I'm refresh still says yeah sure thank you I want to check it out uh individuals the two responses and we are going to run it so directory it's called Google curl hit enter and it did thing it created the file that's what the script was asked to do and then at the end was the C command and and here you go now we have three responses so let's look at the third response so Windows 10 based PC my username so that's what the script does creates oh actually I should show you the text file my username and my IP address IP address and time date so so this is the date and this is the time because that's what we specified so in the script so that's how you'll do um update of a Google form so this is just a very simple example if you have a complicated system a complicated form you want to do some automation that's how you will do it using uh simple curl command so again uh replace the form response or replace the view form with form response get rid of all the other entries that were there that you saw and then make sure you do this part make sure you have Dash D for each individual field if you don't have that if you try to run this as Pur on the original Prill prefill URL that you got it will not work so and make sure that you have at the end dasd submit equal to submit so simple command it works wonderfully uh hopefully you found this video useful and if you did uh please do post below I i' be interested in knowing how you use this to automate or to push out data to your own Google individual forms so um it'll be interesting in Cas I like to know what use cases actually exist for me it's a simple lab Lab machines or what lab virtual machines the IP address might be changing regularly but if I want to remote into them for example instead of using no IP or something like that a client I was able to build something like uh at no cost free uh basically no cloud storage except the Google part I guess Google forms but it's pretty secure now I can fetch this Excel file so if I go link to a sheet let say create this I can link to a file now I have a now I have an Excel file so I got the entries all in an Excel format I can now export download however you want to use this Excel file you can use that so again once again I hope you guys found this interesting and useful and I be interested in uh hearing your use cases looking at what you guys post please do hit the Subscribe button it is much appreciated it helps uh users like me kind of you know uh keep going staying motivated to do more videos like this again guys stay safe take care
Info
Channel: HashTagTnT
Views: 188
Rating: undefined out of 5
Keywords: curl google post, curl post, curl to form post, curl fill google form
Id: RJC0S9otEEU
Channel Id: undefined
Length: 18min 59sec (1139 seconds)
Published: Tue Nov 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.