简体   繁体   English

如何通过 C 编程打开终端中显示的链接?

[英]How to open a link displayed in Terminal via C Programming?

My Project: I am using sensors to gather data and then send it to cloud wirelessly.我的项目:我正在使用传感器收集数据,然后以无线方式将其发送到云端。 I have programmed my WiFi module using the AT Instruction Set in C Programming language.我已经使用 C 编程语言中的 AT 指令集对我的 WiFi 模块进行了编程。 As of now, I get the following result in my terminal.截至目前,我在终端中得到以下结果。

在此处输入图片说明

My Issue: As seen in the above screenshot, after my program executes, I get a link which I have to double-click every time in order to push data to cloud.我的问题:如上面的屏幕截图所示,在我的程序执行后,我得到一个链接,我每次都必须双击该链接才能将数据推送到云端。

My Goal: To program the code (using C Programming Language) in Online Mbed Compiler so that after getting the GET https://api ...... link, my code will ask the terminal to open the link in the default browser.我的目标:在 Online Mbed Compiler 中编写代码(使用 C 编程语言),以便在获得GET https://api ......链接后,我的代码会要求终端在默认浏览器中打开该链接. I am trying to automate the double-clicking part as mentioned before.我正在尝试自动执行前面提到的双击部分。

What line of code(s) should I add to my C program so that it asks the terminal to open the webpage from the GET link that we see in the terminal output as aforementioned?我应该将哪一行代码添加到我的 C 程序中,以便它要求终端从我们在终端输出中看到的GET链接打开网页,如前所述?

Thank you for your time and help.感谢您的时间和帮助。 I apologies, I do not have much experience with terminal and C coding.我很抱歉,我对终端和 C 编码没有太多经验。 So, your help is much appreciated.因此,非常感谢您的帮助。 Thank you very much again!再一次非常感谢你!

EDIT: Terminal I am using: Tera Term.编辑:我使用的终端:Tera Term。

I am also open to opening the link that my program gets, to open it directly without relying on the terminal, if opening the link from terminal is not possible.如果无法从终端打开链接,我也愿意打开我的程序获取的链接,直接打开它而不依赖终端。 Following is a snippet of my code that generates the GET link:以下是我生成 GET 链接的代码片段:

 //Pushing the data acquired from HC-SR04 Ultrasonic Sensor to Cloud Server via API
    sprintf(snd,"GET https://api.thingspeak.com/update?api_key=3LV9GHWHJYDZNWEH&field1=%f \r\n\r\n", dist_percent);
    pc.printf("%s\r",snd);
    wifi.SendCMD(snd);
    wait(1);
    wifi.RcvReply(rcv, 1000);
    pc.printf("%s\r", rcv);

Automating clicks is asking for something to break.自动化点击是要求打破某些东西。 The correct way would be to programmatically follow that link.正确的方法是以编程方式遵循该链接。 Either:任何一个:

A) Program an HTTPS stack to connect to the server (I don't actually recommend this outside of a purely academic endeavor) A) 编写一个 HTTPS 堆栈以连接到服务器(除了纯粹的学术努力之外,我实际上并不推荐这样做)

B) Learn to use libcurl . B) 学习使用libcurl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM