Current Events > Creating a batch script file was the most challenging thing in my IT work life

Topic List
Page List: 1
VeggetaX
06/27/23 11:38:09 AM
#1:


/workblog

I am not a programmer or a script writer and have no experience in it other then running the scripts already created or simple stuff for when I went to college.

I was tasked to create a batch script file to automatically to move 3 daily generated report files on a server to a FTP server on a nightly basis.

Sounds easy on paper but there was so much fucking thing I had to do to get this right. Took me over 2 months. You hit a wall after wall and fall into a bunch of rabbit holes. You fix one part of the script but now the other part is broken and won't work with the newly fixed script. I had some example references from other scripts so that helped a lot and my senior coworker who was to be my main resource was purposely being vague when advising me hoping I'd figure it out mostly on my own. There's just way too much room for mistakes with this kinda stuff. I also don't see the fun in this. I usually love my work in IT but this kinda stuff is completely frustrating because it feels like the system is working against you and not for you. There is a ton of knowledge to this even for the small stuff. Thots?

---
Don't like it? Don't watch it. It's that simple
Dictator of Nice Guys
... Copied to Clipboard!
divot1338
06/27/23 11:41:20 AM
#2:


Question: Do you have sccess to a powerful batch file exitir like Notepad?

---
Moustache twirling villian
https://i.imgur.com/U3lt3H4.jpg- Kerbey
... Copied to Clipboard!
Anarchy_Juiblex
06/27/23 11:42:17 AM
#3:


Hey Chatgpt, do what VeggetaX took 2 months to do...

@echo off setlocal REM Set the source directory where the daily report files are generated set "sourceDirectory=C:\Path\To\Reports" REM Set the destination FTP server details set "ftpServer=ftp.example.com" set "ftpUsername=your_username" set "ftpPassword=your_password" set "ftpDirectory=/destination/directory" REM Set the current date for creating a unique folder on the FTP server set "currentDate=%date:~-4%-%date:~3,2%-%date:~0,2%" REM Create a new folder on the FTP server for the current date echo Creating folder %currentDate% on FTP server... echo open %ftpServer%> ftpscript.txt echo %ftpUsername%>> ftpscript.txt echo %ftpPassword%>> ftpscript.txt echo mkdir %ftpDirectory%/%currentDate%>> ftpscript.txt echo quit>> ftpscript.txt ftp -s:ftpscript.txt del ftpscript.txt REM Move the daily report files to the FTP server echo Moving report files to FTP server... echo open %ftpServer%> ftpscript.txt echo %ftpUsername%>> ftpscript.txt echo %ftpPassword%>> ftpscript.txt echo binary>> ftpscript.txt echo cd %ftpDirectory%/%currentDate%>> ftpscript.txt echo put %sourceDirectory%\report1.txt>> ftpscript.txt echo put %sourceDirectory%\report2.txt>> ftpscript.txt echo put %sourceDirectory%\report3.txt>> ftpscript.txt echo quit>> ftpscript.txt ftp -s:ftpscript.txt del ftpscript.txt echo Reports transferred successfully! endlocal

Make sure to update the following variables in the script:
  • sourceDirectory: Specify the directory where the daily report files are generated on the server.
  • ftpServer: Provide the hostname or IP address of the FTP server.
  • ftpUsername: Enter the FTP server username.
  • ftpPassword: Enter the FTP server password.
  • ftpDirectory: Specify the destination directory on the FTP server where the reports should be stored.
Save the script with a .bat extension (e.g., move_reports.bat) and schedule it to run nightly using the Windows Task Scheduler or any other scheduling tool of your choice.
Note: The script uses the ftp command-line utility available in Windows to transfer files via FTP. Ensure that the utility is installed and accessible on your system.


---
https://en.wikipedia.org/wiki/Straw_man#Steelmanning
https://en.wikipedia.org/wiki/Principle_of_charity
... Copied to Clipboard!
Kaldrenthebold
06/27/23 11:43:06 AM
#4:


Two months for that??

We are moving over a bunch of data across three drives into one new Synology server. My team got a script up to move them over as well as update our automatic FTP of files to clients in like a day.

---
http://i169.photobucket.com/albums/u223/chocolateFRESH/arts/kraid.png - Thanks GP cosmonaut!
http://i.imgur.com/TuJWAR8.jpg
... Copied to Clipboard!
ThisIsAKnoife
06/27/23 11:48:06 AM
#5:


I wrote an SFTP backup script that runs through a counter to store up to 5 days worth of a file nightly. It actively backs up 50 routers nightly. This was Mikrotiks LUA-based language and it took me less than a day to write and spin the server up and configure the networking

---
AFK: Attack, fight, kill!! The healer is telling you to go pull mobs.
Gigabyte RTX 4090 || i9-12900k || 32GB DDR4 3600 || ROG Strix Z690-A
... Copied to Clipboard!
VeggetaX
06/27/23 11:48:19 AM
#6:


divot1338 posted...
Question: Do you have sccess to a powerful batch file exitir like Notepad?
Notepad++

Anarchy_Juiblex posted...
Hey Chatgpt, do what VeggetaX took 2 months to do...

@echo off setlocal REM Set the source directory where the daily report files are generated set "sourceDirectory=C:\Path\To\Reports" REM Set the destination FTP server details set "ftpServer=ftp.example.com" set "ftpUsername=your_username" set "ftpPassword=your_password" set "ftpDirectory=/destination/directory" REM Set the current date for creating a unique folder on the FTP server set "currentDate=%date:~-4%-%date:~3,2%-%date:~0,2%" REM Create a new folder on the FTP server for the current date echo Creating folder %currentDate% on FTP server... echo open %ftpServer%> ftpscript.txt echo %ftpUsername%>> ftpscript.txt echo %ftpPassword%>> ftpscript.txt echo mkdir %ftpDirectory%/%currentDate%>> ftpscript.txt echo quit>> ftpscript.txt ftp -s:ftpscript.txt del ftpscript.txt REM Move the daily report files to the FTP server echo Moving report files to FTP server... echo open %ftpServer%> ftpscript.txt echo %ftpUsername%>> ftpscript.txt echo %ftpPassword%>> ftpscript.txt echo binary>> ftpscript.txt echo cd %ftpDirectory%/%currentDate%>> ftpscript.txt echo put %sourceDirectory%\report1.txt>> ftpscript.txt echo put %sourceDirectory%\report2.txt>> ftpscript.txt echo put %sourceDirectory%\report3.txt>> ftpscript.txt echo quit>> ftpscript.txt ftp -s:ftpscript.txt del ftpscript.txt echo Reports transferred successfully! endlocal

Make sure to update the following variables in the script:
* sourceDirectory: Specify the directory where the daily report files are generated on the server.
* ftpServer: Provide the hostname or IP address of the FTP server.
* ftpUsername: Enter the FTP server username.
* ftpPassword: Enter the FTP server password.
* ftpDirectory: Specify the destination directory on the FTP server where the reports should be stored.
Save the script with a .bat extension (e.g., move_reports.bat) and schedule it to run nightly using the Windows Task Scheduler or any other scheduling tool of your choice.
Note: The script uses the ftp command-line utility available in Windows to transfer files via FTP. Ensure that the utility is installed and accessible on your system.
I have to transfer securely using WinSCP. That means you'll have to script out the file to open the console version of WinSCP which then have their own console commands that you have to use to make it work right.

And then you have to make the script to create log events of every nightly transfer, and have the script to email you if the transfer is successful or not. And if it's not successful, you'll have to have it the log be compressed and gracefully explain why it didn't transfer so you can troubleshoot.

---
Don't like it? Don't watch it. It's that simple
Dictator of Nice Guys
... Copied to Clipboard!
Anarchy_Juiblex
06/27/23 11:52:08 AM
#7:


VeggetaX posted...
I have to transfer securely using WinSCP. That means you'll have to script out the file to open the console version of WinSCP which then have their own console commands that you have to use to make it work right.

And then you have to make the script to create log events of every nightly transfer, and have the script to email you if the transfer is successful or not. And if it's not successful, you'll have to have it the log be compressed and gracefully explain why it didn't transfer so you can troubleshoot.

It can do that too. You should play around with it. It's legit good.

---
https://en.wikipedia.org/wiki/Straw_man#Steelmanning
https://en.wikipedia.org/wiki/Principle_of_charity
... Copied to Clipboard!
Naysaspace
06/27/23 11:53:44 AM
#8:


I did something like this once as a manufacturing planner. It guy tried forever and couldn't get one up (probably didnt try, we were the black sheep new acquisition). The it guy got jelly and removed our critical lab workstation from the network costing us several thousand in productivity lol.

Or purchaser was also bangin the acklands guy for a discount/kickback (which is basically prostitution). I wound up taking over purchasing duties after that lol
... Copied to Clipboard!
VeggetaX
06/27/23 11:54:28 AM
#9:


Kaldrenthebold posted...
Two months for that??

We are moving over a bunch of data across three drives into one new Synology server. My team got a script up to move them over as well as update our automatic FTP of files to clients in like a day.

ThisIsAKnoife posted...
I wrote an SFTP backup script that runs through a counter to store up to 5 days worth of a file nightly. It actively backs up 50 routers nightly. This was Mikrotiks LUA-based language and it took me less than a day to write and spin the server up and configure the networking
A huge wall I ran into early was making sure it detects the files are the correct files so I had to write the script to understand the names and date are correct because the files were generated every day to the same place, replacing the old files previously.

---
Don't like it? Don't watch it. It's that simple
Dictator of Nice Guys
... Copied to Clipboard!
Solid_Sonic
06/27/23 11:55:38 AM
#10:


Batch files are just supposed to be command line arguments that are executed in a sequential fashion. After that you usually set a routine to run via Task Scheduler to call that batch script to run at the appointed time.

---
Surely if I stick up for rich people on the Internet I'll eventually get a sweet job offer from them, right?
... Copied to Clipboard!
VeggetaX
06/27/23 11:55:38 AM
#11:


Anarchy_Juiblex posted...
It can do that too. You should play around with it. It's legit good.
ChatGPT has been a great assistance but it messed up a lot too.

---
Don't like it? Don't watch it. It's that simple
Dictator of Nice Guys
... Copied to Clipboard!
VeggetaX
06/27/23 11:59:07 AM
#12:


Naysaspace posted...
I did something like this once as a manufacturing planner. It guy tried forever and couldn't get one up (probably didnt try, we were the black sheep new acquisition). The it guy got jelly and removed our critical lab workstation from the network costing us several thousand in productivity lol.

Or purchaser was also bangin the acklands guy for a discount/kickback (which is basically prostitution). I wound up taking over purchasing duties after that lol
I wouldn't try to make a guy do something way beyond their knowledge. Throwing someone to the wolves isn't a good way to teach, IMO. When they gave this project to me they knew how long it was going to take and the challenges it had so they pretty much kinda babied me into this.

---
Don't like it? Don't watch it. It's that simple
Dictator of Nice Guys
... Copied to Clipboard!
ThisIsAKnoife
06/27/23 11:59:41 AM
#13:


VeggetaX posted...
ChatGPT has been a great assistance but it messed up a lot too.

I asked it to write a script that initiates an SSH session to a device, login and run a command then write regex to cut the portions I wanted (I gave it a sample output)

It wrote everything but the first most important part of SSHing from the linux box and when I asked it where it was it legit said Oops sorry I forgot about that

---
AFK: Attack, fight, kill!! The healer is telling you to go pull mobs.
Gigabyte RTX 4090 || i9-12900k || 32GB DDR4 3600 || ROG Strix Z690-A
... Copied to Clipboard!
VeggetaX
06/27/23 12:01:46 PM
#14:


Solid_Sonic posted...
Batch files are just supposed to be command line arguments that are executed in a sequential fashion. After that you usually set a routine to run via Task Scheduler to call that batch script to run at the appointed time.
Like I said, it sounds much easier on paper. It's like you have one thing done now you have to do this and that.

---
Don't like it? Don't watch it. It's that simple
Dictator of Nice Guys
... Copied to Clipboard!
superbot400
06/27/23 12:02:53 PM
#15:


VeggetaX posted...
Notepad++

I have to transfer securely using WinSCP. That means you'll have to script out the file to open the console version of WinSCP which then have their own console commands that you have to use to make it work right.

And then you have to make the script to create log events of every nightly transfer, and have the script to email you if the transfer is successful or not. And if it's not successful, you'll have to have it the log be compressed and gracefully explain why it didn't transfer so you can troubleshoot.


Chatgpt literally can do that. Just debug it and test if it works with your environments.


---
http://spinsulin.freeforums.org/the-fantastic-four-respect-thread-t4436.html, my huge ass respect thread. You won't see it.
... Copied to Clipboard!
Topic List
Page List: 1