How to make в multistep command ask for inputs?

Sorry for the confusing title but herВs what I want to do.

I run this command прекратился often:

w3m -dump http://www.example.com/file-to-save-as-text/ > ~/Desktop/saved-file.txt

Is it possible to have в (Zenity?) or plain конечный рукописный шрифт that will allow to пас in the унифицированный указатель ресурса http://www.example.com/file-to-save-as-text/ and then prompt я to type in just the file ямс such схвати saved-file.txt after which w3m will "dump" the унифицированный указатель ресурса contents in ~/Desktop with the file ямс I specified?

In other words, instead of typing in the whole command, гll just need to пас in the унифицированный указатель ресурса (copied from my browser's address бар) and provide в suitable file ямс.

0
задан 9 December 2015 в 19:19

2 ответа

Можно использовать этот сценарий:

#!/bin/bash
url="$(zenity --entry "URL" --title "Enter the URL:" --text "Enter the URL:" 2>/dev/null)"
filename="$(zenity --entry "filename" --title "Enter the filename:" --text "Enter the filename:" 2>/dev/null)"
w3m -dump "$url" > ~/Desktop/"$filename"
  • url="$(zenity --entry "URL" --title "Enter the URL:" --text "Enter the URL:" 2>/dev/null)": подсказки для URL и хранилищ вход в $url;
  • filename="$(zenity --entry "filename" --title "Enter the filename:" --text "Enter the filename:" 2>/dev/null)": подсказки для имени файла и хранилищ вход в $filename;
  • w3m -dump "$url" > ~/Desktop/"$filename": выполняет w3m -dump на $url и перенаправляет вывод к ~/Desktop/"$filename".
1
ответ дан 30 September 2019 в 02:03

Вы могли использовать что-то вроде этого:

#!/bin/bash

echo "enter URL"
read URL
echo "enter filename"
read NAME

w3m -dump "$URL" > "$NAME"

можно сохранить это как run_w3m.sh, сделать это исполняемым файлом с chmod 755 run_w3m.sh и выполнить его с ./run_w3m.sh. Сценарий попросит URL и путь к файлу.

1
ответ дан 30 September 2019 в 02:03

Другие вопросы по тегам:

Похожие вопросы: