rmyorston / busybox-w32

WIN32 native port of BusyBox.
https://frippery.org/busybox
Other
695 stars 126 forks source link

doubt about the use applets #307

Closed Hangaro0 closed 1 year ago

Hangaro0 commented 1 year ago

Thank you very much for busybox, English is not my language, I am new to everything :D


SYNTAX busybox [arguments...] all ok ....

but ... I was wondering if there is a way to use something similar to this..... Is there any way to use it applets like this? .. use busybox.exe section like this..

curl --url "https://www.ipaddress.com/what-is-my-ip-address/es/cu%c3%a1l-es-mi-direcci%c3%b3n-ip" | busybox.exe "[grep 'th..td id..ipv4...a class..ip ipv4' | sed 's/.https/https/g ; s/.>.//g' | ... | ... ]"

I tried it like this and it didn't work If there is no way to do it like this, some other similar to the one suggested I searched the internet for some way to group them but I did not find anything .... .. from busybox-help .. brackets? COMMANDS Currently available applets include: [, [[, acpid, addgroup,..... .... SYNTAX with brackets ?? busybox "[ applet1 arguments | applet2 arguments | applet3 arguments | ... | ... ]" .... If it is something like that, I would like an example of how it should be done.

thanks for suggestions

rmyorston commented 1 year ago

busybox [arguments...]

The square brackets are just a convention used in documentation. They indicate something is optional. In this case the arguments can be omitted.

In the BusyBox shell square brackets do have special meanings but grouping commands isn't one of them.

There are different ways to do what you're asking.

The simplest is probably to start the BusyBox shell with the command busybox sh. Then you don't need to specify busybox.exe to run any of the included applets. So something like this would work:

curl --url "https://www...." | grep 'th..td id..ipv4...a class..ip ipv4' | sed 's/.https/https/g ; s/.>.//g'

Another way is:

curl --url "https://www...." | busybox grep 'th..td id..ipv4...a class..ip ipv4' | busybox sed 's/.https/https/g ; s/.>.//g'
Hangaro0 commented 1 year ago

rmyorston .. Thanks for such a quick response .. :D

I tried with a "sh-file" and it didn't work .. maybe because of the "exe-program" .. "curl.exe".. .. or if this is possible how do I call it . or how would it work in a "bat-file" ? .. how is it used in a "batch-file" ? .. "curl.exe"


@echo off busybox.exe sh curl.exe --proxy "http://127.0.0.1:8118" --http1.1 --ipv4 --connect-timeout 5 --user-agent "%UserAgent%" --head --url "https://www.google.com.mx/?hl=es-419" grep -e "^HTTP" -e "^Date" .. ... ... .. ... ..

please give me an example I thank you very much for your time

rmyorston commented 1 year ago

My suggestion of busybox sh was for interactive use. So if you had a Command Prompt you could do:

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\rmy>busybox sh
~ $ curl -url "https://..." | grep -e "^HTTP" -e "^Date"

This makes is possible to mix external programs (like curl) with BusyBox applets (like grep).

I'm not really the right person to ask about batch files. I'll just recommend using shell scripts instead!

Hangaro0 commented 1 year ago

you're very kind. thanks for your sincerity .. :D

ale5000-git commented 1 year ago

rmyorston .. Thanks for such a quick response .. :D

I tried with a "sh-file" and it didn't work .. maybe because of the "exe-program" .. "curl.exe".. .. or if this is possible how do I call it . or how would it work in a "bat-file" ? .. how is it used in a "batch-file" ? .. "curl.exe"

@echo off busybox.exe sh curl.exe --proxy "http://127.0.0.1:8118" --http1.1 --ipv4 --connect-timeout 5 --user-agent "%UserAgent%" --head --url "https://www.google.com.mx/?hl=es-419" | grep -e "^HTTP" -e "^Date" .. ... ... .. ... ..

please give me an example I thank you very much for your time

Just this:

@echo off
curl.exe --proxy "http://127.0.0.1:8118/" --http1.1 --ipv4 --connect-timeout 5 --user-agent "%UserAgent%" --head --url "https://www.google.com.mx/?hl=es-419" | busybox.exe grep -e "^HTTP" -e "^Date"
Hangaro0 commented 1 year ago
hello "ale5000-git" .. English is not my language, so it must be difficult to make myself understand .. As I see, different doubts arise. It's clear to me that you can't .. .... SYNTAX with brackets ?? busybox "[ applet1 arguments applet2 arguments applet3 arguments ... ... ]" .... in "file-bat" it goes well but i feel like i am between two worlds to use only "sh" or "batch" .. now I want create a "file-sh" and invoke exe programs (like curl.exe with arguments) ..? -- --- --test.sh -- --- -- run the program curl.exe with arguments in a sh file, how is it done?

!/bin/bash

... ... ... ... ... curl.exe --request POST --url 'https://www.virustotal.com/vtapi/v2/file/report' --form 'apikey=123' --form 'resource=123' sed 's ^{.scans.: { g' sed 's }, }\n g' sed 's ^ g' sed '/detected.: false, .version/d' sed 's , .version.*result.: . --- result \: g' sed 's .. .update.: .*$ g' sed 's \", \" \n g' sed 's \": {\" : g' ... ... ... ... ... ...

busybox.exe sh "test.sh"

Apparently it cannot be done or something else must be done to make it happen. I thank you interest :D

ale5000-git commented 1 year ago

!/bin/bash ... ... ... ... ... curl.exe --request POST --url 'https://www.virustotal.com/vtapi/v2/file/report' --form 'apikey=123' --form 'resource=123' | sed 's|^{.scans.: {||g' | sed 's|},|}\n|g' | sed 's|^ ||g' | sed '/detected.: false, .version/d' | sed 's|, .version.result.: .| --- result : |g' | sed 's|.. .update.: .$||g' | sed 's|", "|\n|g' | sed 's|": {"| : |g' ... ... ... ... ... ...

busybox.exe sh "test.sh"

Apparently it cannot be done or something else must be done to make it happen. I thank you interest :D

It should work, what error do you get?

Hangaro0 commented 1 year ago

I am very grateful to you for continuing my case :D when executing "file.sh" everything closes.. I am aware that it is my fault for not knowing the subject. I'm starting to appreciate "sh-file" . in bath file I understand how it works... but I don't want to be jumping between one and the other; bat(with sections busybox) or sh(get totally busybox). unfortunately I am very new, I don't know how to explain what happens, causes or reasons... what I would like is to see examples of how others do it, unfortunately I can't find a site where something similar is carried out. I would like to see examples of how to run an "exe executable" from a sh file... I appreciate the support you give me, if you know a "site" where "windows users" expose "busybox-sh" scripts to observe how they execute "exe executables" I feel that I am abusing your time, and I am still very lost on the subject.

Hangaro0 commented 1 year ago

.. .. I was able to ":D".. thanks for your support .. it was something very simple .. go to the path of the executable and add that the executable is there. ..


cd 'Documents/Softw-Portable/curl' ./curl.exe --proxy 'http://127.0.0.1:8118' --http1.1 --ipv4 --connect-timeout 5 --user-agent 'Mozilla/5.0 (Mobile; ALCATEL 4056W; rv:84.0) Gecko/84.0 Firefox/84.0 KAIOS/3.0' --head --url 'https://www.google.com.mx/?hl=es-419' grep -e '^HTTP' -e '^Date'

rmyorston and ale5000 .. Thanks for your patience and time. From here I just have to play with this new world

ale5000-git commented 1 year ago

You can also avoid changing directory and directly specify the full path, example: 'c:/folder_name/curl.exe' --proxy 'http://127.0.0.1:8118/' --http1.1 --ipv4 --connect-timeout 5 --user-agent 'Mozilla/5.0 (Mobile; ALCATEL 4056W; rv:84.0) Gecko/84.0 Firefox/84.0 KAIOS/3.0' --head --url 'https://www.google.com.mx/?hl=es-419' | grep -e '^HTTP' -e '^Date'

PS: I usually always put things in quotes (' or ") so that it works also with path containg spaces.