Как сделать скриншот за $1 секунду, загрузить и получить ссылку с ompdlr.org

scrotit(){ echo "Screenshot in $1 seconds...";scrot -d $1 '%Y%m%d%h.png' -e 'curl -sF file1=@- http://ompldr.org/upload < $f | grep -P -o "(?<=File:).*(http://ompldr.org/.*)\";rm $f'| sed -r 's@.*(http://ompldr.org/\w{1,7}).*@\1@';}


scrotit() is a custom function that takes an argument representing the delay in seconds. It captures a screenshot after the specified delay and uploads it to ompdlr.org, a file hosting platform. The function then returns the URL of the uploaded screenshot.

To achieve this, the function uses the external command «scrot» to capture the screenshot with the specified delay. It saves the screenshot with a filename in the format «%y%m%d%h.png», where %y%m%d%h represents the current date and time. The «-d» option is used to specify the delay in seconds.

After capturing the screenshot, the function uses a series of commands to upload the file to ompdlr.org. It uses the «curl» command to send a POST request containing the file to the upload endpoint: «http://ompldr.org/upload». The file is read from standard input using the «< $f" redirect. The response from the server is then filtered to extract the URL of the uploaded file using the "grep" command, with the "-p -o" options to output only the matched substring.

Finally, the function deletes the temporary screenshot file using the "rm" command and extracts the URL from the filtered response using the "sed" command. The extracted URL is then printed as the output of the function.

An alternative to this custom function would be to use a combination of existing commands such as "scrot" or "import" for capturing the screenshot and then using another command or script to upload the file to ompdlr.org and obtain the URL. However, the custom function "scrotit()" combines these steps into a single command for convenience.

Ответить

Ваш адрес email не будет опубликован. Обязательные поля помечены *