Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 16 Jul 2018, 02:50
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Script installs Windows apps in Wine.
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
mos

Joined: 01 Oct 2016
Posts: 6

PostPosted: Sat 01 Oct 2016, 13:31    Post subject:  Script installs Windows apps in Wine.  

Hello Puppy community ,this is my first writing , in this forum.I often read here the postings ,especially those about gtkdialog scripting.The thing is that i'm not good at bash scripting.So I need some help in this direction.
Now I want to create a script to automate the install of windows apps on linux through wine.So i thought that to accomplish this I need to create a script that makes a text file for every .exe and .msi file from a directory ,naming the text files after the apps.I used as source for this a topic from this area and I came up with this script ,that partially works:
Code:

#!/bin/bash

HERE="$(dirname "$(readlink -f "${0}")")"

rm -f /tmp/txt

cd $HERE

find . -maxdepth 1 -type f \( -name "*.exe" -o -name "*.msi" \) -print > /tmp/txt

fgs=/tmp/txt
while IFS='' read -r line || [[ -n "$line" ]]; do
    echo 'This is a test' > $line.txt
done < "$fgs"



I wanted to replace 'This is a test' with the second script code , but the resulting text was so compacted that it was useless.The second script:
Code:

#!/bin/bash

env WINEPREFIX="/home/lns/.wine" /opt/wine-staging/bin/wine Z:\\\\tmp\\\\$line &

sleep 3
xdotool windowactivate
sleep 3
xdotool key Return
sleep 2
xdotool key space
sleep 2
xdotool key Return
sleep 2
xdotool key Down
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Delete
sleep 2
xdotool type "C:\Program Files\VSTPlugins"
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Return
sleep 2
xdotool key Return

Then I tried a different approach considering that will be easier just to put the second script in the directory with exe and msi apps and use another script (third) to make a copy of the second one for every exe,msi file and after that to rename those second script copies with the names of apps ,followed by txt extension to differentiate them from real apps.And finally to replace the $line variable from those copies with the name of corresponding exe and msi apps.But after surfing with no luck this forum and askubuntu in search of a way how to copy and rename files I finally gave up.So how could it be done?I really want to make this automate install of windows apps to work from some script.Thank in advance.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1548
Location: Japan

PostPosted: Sat 01 Oct 2016, 23:25    Post subject: Re: Complex script  

Your script does not need to be complex. You don't need a tmp file when you put the output of the find command into a variable. You can echo the complete second script into the target file. No need for a line-by-line process. The only thing you have to take care of are quotations: If you put the complete string of the second script into double quotes, any double quote within the script has to be escaped (or replaced by single quotes if appropriate).

I hope that this is close to what you are trying to achieve:
Code:
#!/bin/sh
HERE="$(dirname "$(readlink -f "${0}")")"
cd $HERE

LIST=$(find . -maxdepth 1 -type f \( -name "*.exe" -o -name "*.msi" \) )

IFS=$'\n'
for file in $LIST ; do

echo -n "#!/bin/bash
env WINEPREFIX=\"/home/lns/.wine\" /opt/wine-staging/bin/wine Z:\\\\tmp\\\\$line &
sleep 3
xdotool windowactivate
sleep 3
xdotool key Return
sleep 2
xdotool key space
sleep 2
xdotool key Return
sleep 2
xdotool key Down
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Delete
sleep 2
xdotool type \"C:\Program Files\VSTPlugins\"
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Return
sleep 2
xdotool key Return" > "${file}.txt"

done


This is even easier and probably what you asked for at the end of your post. Put your 2nd script into a file, then copy this file for each .exe. and .msi to files renamed <name.exe>.txt or <name.msi>.txt. This assumes that all files are located in the HERE directory, otherwise use full paths.
Code:
#!/bin/sh
HERE="$(dirname "$(readlink -f "${0}")")"
cd $HERE

for file in *.{exe,msi} ; do
cp secondscript.txt "$file".txt
done
Back to top
View user's profile Send private message 
mos

Joined: 01 Oct 2016
Posts: 6

PostPosted: Sun 02 Oct 2016, 13:55    Post subject:  

Thank you Mochi.Your solutions are helpful but something isn't fully working in both situations(solutions).So here's what I've done :I created the script1 provided by you :

Code:


#!/bin/bash
HERE="$(dirname "$(readlink -f "${0}")")"
cd $HERE

LIST=$(find . -maxdepth 1 -type f \( -name "*.exe" -o -name "*.msi" \) )

IFS=$'\n'
for file in $LIST ; do

echo -n "#!/bin/bash

env WINEPREFIX=\"/home/lns/.wine\" /opt/wine-staging/bin/wine Z:\\\\media\\\\SDA\\\\VST\\\\VSTe\\\\$file &

sleep 3
xdotool windowactivate
sleep 3
xdotool key Return
sleep 2
xdotool key space
sleep 2
xdotool key Return
sleep 2
xdotool key Down
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Delete
sleep 2
xdotool type \"C:\Program Files\VSTPlugins\"
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Return
sleep 2
xdotool key Return" > "${file}.txt"

done


When used ,it makes a *.txt file for every exe ,msi file ,with the names of exe,msi files.This is good.But for example the inside of one file looks like this:

Code:

#!/bin/bash

env WINEPREFIX="/home/lns/.wine" /opt/wine-staging/bin/wine Z:\\media\\SDA\\VST\\VSTe\\./BlueCatFreewarePackVST3Setup.exe &

sleep 3
xdotool windowactivate
sleep 3
xdotool key Return
sleep 2
xdotool key space
sleep 2
xdotool key Return
sleep 2
xdotool key Down
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Delete
sleep 2
xdotool type "C:\Program Files\VSTPlugins"
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Return
sleep 2
xdotool key Return


The line:
Code:

Z:\\media\\SDA\\VST\\VSTe\\./BlueCatFreewarePackVST3Setup.exe &

Is wrong because in has only 2 slashes in the path that wine reads and it has to be 4 of them to work.So in the script1 I doubled the number to 8 slashes.I don't know if it's a good thing but this solved the path problem.Another problem that I can't solve is this:
Code:

./BlueCatFreewarePackVST3Setup.exe

In front of BlueCatFreewarePackVST3Setup.exe shouldn't be this "./"
I modified the slashes and now the script1 looks like this:
Code:

#!/bin/bash
HERE="$(dirname "$(readlink -f "${0}")")"
cd $HERE

LIST=$(find . -maxdepth 1 -type f \( -name "*.exe" -o -name "*.msi" \) )

IFS=$'\n'
for file in $LIST ; do

echo -n "#!/bin/bash

env WINEPREFIX=\"/home/lns/.wine\" /opt/wine-staging/bin/wine Z:\\\\\\\\media\\\\\\\\SDA\\\\\\\\VST\\\\\\\\VSTe\\\\\\\\$file &

sleep 3
xdotool windowactivate
sleep 3
xdotool key Return
sleep 2
xdotool key space
sleep 2
xdotool key Return
sleep 2
xdotool key Down
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Delete
sleep 2
xdotool type \"C:\Program Files\VSTPlugins\"
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Return
sleep 2
xdotool key Return" > "${file}.txt"

done


The result of using it is this:
Code:

#!/bin/bash

env WINEPREFIX="/home/lns/.wine" /opt/wine-staging/bin/wine Z:\\\\media\\\\SDA\\\\VST\\\\VSTe\\\\./BlueCatFreewarePackVST3Setup.exe &

sleep 3
xdotool windowactivate
sleep 3
xdotool key Return
sleep 2
xdotool key space
sleep 2
xdotool key Return
sleep 2
xdotool key Down
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Delete
sleep 2
xdotool type "C:\Program Files\VSTPlugins"
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Return
sleep 2
xdotool key Return

In front of BlueCatFreewarePackVST3Setup.exe still persists this "./"

Concerning the second script you wrote, this is how I adapted it:

Code:

#!/bin/sh
HERE="$(dirname "$(readlink -f "${0}")")"
cd $HERE

for file in "*".{exe,msi} ; do
cp xdotool-vste "$file".txt
done


xdotool-vste is the name of the file that is copied.The result of using script2 is a single file not one for every exe,msi file and it's name is : *.{exe,msi}.txt .It's content is good but the variable $file is not modified so the result is this:

Code:


#!/bin/bash

env WINEPREFIX="/home/a/.wine" /opt/wine-staging/bin/wine Z:\\\\media\\\\SDA\\\\VST\\\\VSTe\\\\$file &

sleep 3
xdotool windowactivate
sleep 3
xdotool key Return
sleep 2
xdotool key space
sleep 2
xdotool key Return
sleep 2
xdotool key Down
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Delete
sleep 2
xdotool type "C:\Program Files\VSTPlugins"
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Return
sleep 2
xdotool key Return


What should be done next?
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1548
Location: Japan

PostPosted: Sun 02 Oct 2016, 22:25    Post subject:  

mos wrote:
So in the script1 I doubled the number to 8 slashes.I don't know if it's a good thing but this solved the path problem.
Looks odd, but it is correct. Bash uses the backslash as an escape character, so when you need a literal backslash you need 2 of them.

Quote:
Another problem that I can't solve is this:
Code:

./BlueCatFreewarePackVST3Setup.exe

In front of BlueCatFreewarePackVST3Setup.exe shouldn't be this "./"
This is a result of your find command. I don't like the use of the find command here anyway.
Try this:
Code:
#!/bin/sh
HERE="$(dirname "$(readlink -f "${0}")")"
cd $HERE

for file in *.{exe,msi} ; do
echo -n "#!/bin/bash

env WINEPREFIX=\"/home/lns/.wine\" /opt/wine-staging/bin/wine Z:\\\\\\\\media\\\\\\\\SDA\\\\\\\\VST\\\\\\\\VSTe\\\\\\\\$file &

sleep 3
xdotool windowactivate
sleep 3
xdotool key Return
sleep 2
xdotool key space
sleep 2
xdotool key Return
sleep 2
xdotool key Down
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Delete
sleep 2
xdotool type \"C:\Program Files\VSTPlugins\"
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Tab
sleep 2
xdotool key Return
sleep 2
xdotool key Return
sleep 2
xdotool key Return" > "${file}.txt"

done
Back to top
View user's profile Send private message 
mos

Joined: 01 Oct 2016
Posts: 6

PostPosted: Mon 03 Oct 2016, 08:32    Post subject:  

A huge thank you ,a big hug and a box of beers for you Mochi.It works.
Many thanks for your help.
Now , if I'm not asking too much ,how could I adapt your script or make a new one to include in a single text file, the names of all the .zip,.rar and .7z files from one directory and look like this:
Code:

#!/bin/bash

echo -e "\n"
read -s -n1 -p " Press any key to continue"
echo -e "\n"
echo -e "\033[01;38;5;220m  \n                     * INSTALLING VSTi Bass * \033[0m"
echo -e "\n"

HVST=/media/SDA/VST/VSTi/Bass

mkdir ~/.wine/drive_c/Program\ Files/VSTPlugins/$file
cd ~/.wine/drive_c/Program\ Files/VSTPlugins/$file
7z x $HVST/$file.zip &&

mkdir ~/.wine/drive_c/Program\ Files/VSTPlugins/$file
cd ~/.wine/drive_c/Program\ Files/VSTPlugins/$file
7z x $HVST/$file.zip &&

mkdir ~/.wine/drive_c/Program\ Files/VSTPlugins/$file
cd ~/.wine/drive_c/Program\ Files/VSTPlugins/$file
7z x $HVST/$file.zip &&

.
.
.
.
.
.
.
.

mkdir ~/.wine/drive_c/Program\ Files/VSTPlugins/$file
cd ~/.wine/drive_c/Program\ Files/VSTPlugins/$file
7z x $HVST/$file.zip &&

echo -e "\n"
read -s -n1 -p " Press any key to Close"

How to tell bash to create a new entry on that text file in the form of:
Code:

mkdir ~/.wine/drive_c/Program\ Files/VSTPlugins/$file
cd ~/.wine/drive_c/Program\ Files/VSTPlugins/$file
7z x $HVST/$file.zip &&

for every archive file ,and replace the $file with the name of the file ,without it's extension(.zip ,.rar or .7z)?
And ,how to tell bash to adapt the value of $HVST variable according to the path of the directory where i'll put the script that creates the text file?
So there will be two files in every directory that contains .zip.rar.7z files:first ,a script and second a text file.The script should create the text file that looks like in the first example above.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0508s ][ Queries: 11 (0.0035s) ][ GZIP on ]