Contenidos
Ejemplo de script suma en Bash
1 |
echo $1+$2 | bc |
Script en PowerShell que crear el interfaz y llama al script en Bash con WSL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
$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() |