I try to get github token from a file while pushing sth. For example, if I add -S flag to sudo commands, it can read from stdin. I try to achieve sth like this. I'm using C. When the code snippet system("git push origin main") runs and terminal asks me username and token, i want that they are filled auto. What can i do? Thanks in advance.
Asked
Active
Viewed 30 times
0
-
2Consider using ssh keys and an ssh agent instead. Then you don't need to enter your password. It's easier, more convenient, and more secure. https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent – Schwern Feb 03 '23 at 16:05
-
1If the program reads from `/dev/tty` then you have to use a pty to feed it data. The `Expect` package includes utilities to make this easier. – Barmar Feb 03 '23 at 16:29
-
@Schwern thanks for suggestion. In fact, I try to make this thing via tokens but it will be in my mind. – MyZeths Feb 03 '23 at 16:53
-
@Barmar i am super newbie for these topics and so i couldnt get your idea. if you can expand your comment i will be appreciated, if you can say what should i do i will be super helpful. – MyZeths Feb 03 '23 at 16:53
-
Newbie or not, you're still expected to do your own research and try to code it first. We'll help yuo fix it, we won't write it for you – Barmar Feb 03 '23 at 17:00
-
@Barmar in fact my code is ready just this part and i have been struggling for this problem for 10 hour, but you have right points. The problem for my issue is that idk how to research the answer bcz i just dived into this thing without any knowledge, my request was a just starting point to research (idk even what /dev/tty is) otherwise i dont want to just copy&paste i hope i could explain myself properly. thanks for your info again although probably i wont find anything works for me – MyZeths Feb 03 '23 at 17:23