Contenidos
Ejemplo de script suma en Bash
echo $1+$2 | bc
Script en PowerShell que crear el interfaz y llama al script en Bash con WSL
$form = [System.Windows.Forms.Form] @{ Text = 'Mi formulario' } $Label1 = [System.Windows.Forms.Label] @{ Text = "Número 1" Location = "40,20" } $TextBox1 = [System.Windows.Forms.TextBox] @{ Text = "" Location = "150,20" } $Label2 = [System.Windows.Forms.Label] @{ Text = "Número 2" Location = "40,50" } $TextBox2 = [System.Windows.Forms.TextBox] @{ Text = "" Location = "150,50" } $Button1 = [System.Windows.Forms.Button] @{ Text = "+" Location = "20,100" } $Button2 = [System.Windows.Forms.Button] @{ Text = "-" Location = "110,100" } $Button3 = [System.Windows.Forms.Button] @{ Text = "*" Location = "200,100" } $TextBox3 = [System.Windows.Forms.TextBox] @{ Text = "" Location = "100,150" } function suma() { $num1 = [Int]$TextBox1.text $num2 = [Int]$TextBox2.text $suma = wsl sh /root/suma.sh $num1 $num2 $TextBox3.Text = $suma } function resta() { $num1 = [Int]$TextBox1.text $num2 = [Int]$TextBox2.text $resta = wsl sh /root/resta.sh $num1 $num2 $TextBox3.Text = $resta } function multi() { $num1 = [Int]$TextBox1.text $num2 = [Int]$TextBox2.text $multi = wsl sh /root/multi.sh $num1 $num2 $TextBox3.Text = $multi } $Button1.add_click({suma}) $Button2.add_click({resta}) $Button3.add_click({multi}) $form.Controls.Add($Label1) $form.Controls.Add($TextBox1) $form.Controls.Add($Label2) $form.Controls.Add($TextBox2) $form.Controls.Add($Button1) $form.Controls.Add($Button2) $form.Controls.Add($Button3) $form.Controls.Add($TextBox3) $form.ShowDialog()