How to execute an exe using shell script? [closed]
Clash Royale CLAN TAG#URR8PPP
I have an exe, which takes 2 .csv files as input. As below:
cSplittinglines.exe srcdirfile.csv destdirfile.csv
How can I execute this .exe using a shell script so that the directory from which the script is run has no impact on the location of the exe. aka avoid hard coding the exe path. Below is the script I am working on.
#!/bin/sh
STARTTIME=`date '+%Y%m%d.%H%M%S'`
LOGFILE=$ERRDIR/$0.$STARTTIME
SplitDir=$1
LyxlamDir=$2
echolog ()
echo $*
echo $* >> $LOGFILE
for file in "$SplitDir"/*; do
if [ -d "$file" ]; then continue; fi
extension=$file##*.
if [ "$extension" = "csv" ]
then
cSplittingLines.exe "$file" "$LyxlamDir"
mv "$file" "$SplitDir/old"
fi
done
bash shell-script shell scripting
closed as unclear what you're asking by Rui F Ribeiro, Michael Homer, Ipor Sircer, Archemar, Christopher Jan 24 at 16:35
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I have an exe, which takes 2 .csv files as input. As below:
cSplittinglines.exe srcdirfile.csv destdirfile.csv
How can I execute this .exe using a shell script so that the directory from which the script is run has no impact on the location of the exe. aka avoid hard coding the exe path. Below is the script I am working on.
#!/bin/sh
STARTTIME=`date '+%Y%m%d.%H%M%S'`
LOGFILE=$ERRDIR/$0.$STARTTIME
SplitDir=$1
LyxlamDir=$2
echolog ()
echo $*
echo $* >> $LOGFILE
for file in "$SplitDir"/*; do
if [ -d "$file" ]; then continue; fi
extension=$file##*.
if [ "$extension" = "csv" ]
then
cSplittingLines.exe "$file" "$LyxlamDir"
mv "$file" "$SplitDir/old"
fi
done
bash shell-script shell scripting
closed as unclear what you're asking by Rui F Ribeiro, Michael Homer, Ipor Sircer, Archemar, Christopher Jan 24 at 16:35
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
You seem to have a strange mix of Windows executable and paths and Unix shell script. What is the context you're working in for that to happen?
– Michael Homer
Jan 24 at 4:16
yes,its a windows exe. We always use shell script for windows exe,which works fine,so as to pass the parameters for the exe. We have a MKS tool which also takes shell script in windows.
– Raghav manchale
Jan 24 at 4:20
3
That's probably a relevant element for you to include in the question, and anything else about the environment that might help someone to answer.
– Michael Homer
Jan 24 at 4:22
1
What is going wrong? Show us (in the question). “Something goes wrong some where”, is not useful, and will not help us spot an error.
– ctrl-alt-delor
Jan 24 at 8:00
1
Try adding anecho about to run cSplittingLines.exe
to the script, that way you can see if it gets to this bit of the script. Alternatively turn on shell tracing.
– ctrl-alt-delor
Jan 24 at 8:03
add a comment |
I have an exe, which takes 2 .csv files as input. As below:
cSplittinglines.exe srcdirfile.csv destdirfile.csv
How can I execute this .exe using a shell script so that the directory from which the script is run has no impact on the location of the exe. aka avoid hard coding the exe path. Below is the script I am working on.
#!/bin/sh
STARTTIME=`date '+%Y%m%d.%H%M%S'`
LOGFILE=$ERRDIR/$0.$STARTTIME
SplitDir=$1
LyxlamDir=$2
echolog ()
echo $*
echo $* >> $LOGFILE
for file in "$SplitDir"/*; do
if [ -d "$file" ]; then continue; fi
extension=$file##*.
if [ "$extension" = "csv" ]
then
cSplittingLines.exe "$file" "$LyxlamDir"
mv "$file" "$SplitDir/old"
fi
done
bash shell-script shell scripting
I have an exe, which takes 2 .csv files as input. As below:
cSplittinglines.exe srcdirfile.csv destdirfile.csv
How can I execute this .exe using a shell script so that the directory from which the script is run has no impact on the location of the exe. aka avoid hard coding the exe path. Below is the script I am working on.
#!/bin/sh
STARTTIME=`date '+%Y%m%d.%H%M%S'`
LOGFILE=$ERRDIR/$0.$STARTTIME
SplitDir=$1
LyxlamDir=$2
echolog ()
echo $*
echo $* >> $LOGFILE
for file in "$SplitDir"/*; do
if [ -d "$file" ]; then continue; fi
extension=$file##*.
if [ "$extension" = "csv" ]
then
cSplittingLines.exe "$file" "$LyxlamDir"
mv "$file" "$SplitDir/old"
fi
done
bash shell-script shell scripting
bash shell-script shell scripting
edited Jan 24 at 17:33
user1133275
3,357723
3,357723
asked Jan 24 at 4:13
Raghav manchaleRaghav manchale
111
111
closed as unclear what you're asking by Rui F Ribeiro, Michael Homer, Ipor Sircer, Archemar, Christopher Jan 24 at 16:35
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Rui F Ribeiro, Michael Homer, Ipor Sircer, Archemar, Christopher Jan 24 at 16:35
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
You seem to have a strange mix of Windows executable and paths and Unix shell script. What is the context you're working in for that to happen?
– Michael Homer
Jan 24 at 4:16
yes,its a windows exe. We always use shell script for windows exe,which works fine,so as to pass the parameters for the exe. We have a MKS tool which also takes shell script in windows.
– Raghav manchale
Jan 24 at 4:20
3
That's probably a relevant element for you to include in the question, and anything else about the environment that might help someone to answer.
– Michael Homer
Jan 24 at 4:22
1
What is going wrong? Show us (in the question). “Something goes wrong some where”, is not useful, and will not help us spot an error.
– ctrl-alt-delor
Jan 24 at 8:00
1
Try adding anecho about to run cSplittingLines.exe
to the script, that way you can see if it gets to this bit of the script. Alternatively turn on shell tracing.
– ctrl-alt-delor
Jan 24 at 8:03
add a comment |
1
You seem to have a strange mix of Windows executable and paths and Unix shell script. What is the context you're working in for that to happen?
– Michael Homer
Jan 24 at 4:16
yes,its a windows exe. We always use shell script for windows exe,which works fine,so as to pass the parameters for the exe. We have a MKS tool which also takes shell script in windows.
– Raghav manchale
Jan 24 at 4:20
3
That's probably a relevant element for you to include in the question, and anything else about the environment that might help someone to answer.
– Michael Homer
Jan 24 at 4:22
1
What is going wrong? Show us (in the question). “Something goes wrong some where”, is not useful, and will not help us spot an error.
– ctrl-alt-delor
Jan 24 at 8:00
1
Try adding anecho about to run cSplittingLines.exe
to the script, that way you can see if it gets to this bit of the script. Alternatively turn on shell tracing.
– ctrl-alt-delor
Jan 24 at 8:03
1
1
You seem to have a strange mix of Windows executable and paths and Unix shell script. What is the context you're working in for that to happen?
– Michael Homer
Jan 24 at 4:16
You seem to have a strange mix of Windows executable and paths and Unix shell script. What is the context you're working in for that to happen?
– Michael Homer
Jan 24 at 4:16
yes,its a windows exe. We always use shell script for windows exe,which works fine,so as to pass the parameters for the exe. We have a MKS tool which also takes shell script in windows.
– Raghav manchale
Jan 24 at 4:20
yes,its a windows exe. We always use shell script for windows exe,which works fine,so as to pass the parameters for the exe. We have a MKS tool which also takes shell script in windows.
– Raghav manchale
Jan 24 at 4:20
3
3
That's probably a relevant element for you to include in the question, and anything else about the environment that might help someone to answer.
– Michael Homer
Jan 24 at 4:22
That's probably a relevant element for you to include in the question, and anything else about the environment that might help someone to answer.
– Michael Homer
Jan 24 at 4:22
1
1
What is going wrong? Show us (in the question). “Something goes wrong some where”, is not useful, and will not help us spot an error.
– ctrl-alt-delor
Jan 24 at 8:00
What is going wrong? Show us (in the question). “Something goes wrong some where”, is not useful, and will not help us spot an error.
– ctrl-alt-delor
Jan 24 at 8:00
1
1
Try adding an
echo about to run cSplittingLines.exe
to the script, that way you can see if it gets to this bit of the script. Alternatively turn on shell tracing.– ctrl-alt-delor
Jan 24 at 8:03
Try adding an
echo about to run cSplittingLines.exe
to the script, that way you can see if it gets to this bit of the script. Alternatively turn on shell tracing.– ctrl-alt-delor
Jan 24 at 8:03
add a comment |
1 Answer
1
active
oldest
votes
Just put the exe on your $PATH (That is what it is for) (%PATH% on Windows)
mv cSplittingLines.exe /bin/
or
echo "export PATH="$PATH:/path/to/exe"" >> ~/.bashrc
Also https://www.shellcheck.net said;
SC2006: Use $(...) notation instead of legacy backticked `...`.
SC2086: Double quote to prevent globbing and word splitting.
Or specify directory and name, in script.
– ctrl-alt-delor
Jan 24 at 8:04
1
@ctrl-alt-delor I assume by " I don't want it as hard coded" he ment he did not want that. Maybe he will clarify.
– user1133275
Jan 24 at 8:23
1
ya.. the directory and file path should not be hard coded.
– Raghav manchale
Jan 24 at 12:19
What about"$(dirname $0)/…/cSplittingLines.exe"
replace the … with the relative path.
– ctrl-alt-delor
Jan 24 at 16:13
@ctrl-alt-delor yah any relative path would work if the 2 were kept relative to eachother but the ambiguity of the question led me to the more robust solution.
– user1133275
Jan 24 at 17:35
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just put the exe on your $PATH (That is what it is for) (%PATH% on Windows)
mv cSplittingLines.exe /bin/
or
echo "export PATH="$PATH:/path/to/exe"" >> ~/.bashrc
Also https://www.shellcheck.net said;
SC2006: Use $(...) notation instead of legacy backticked `...`.
SC2086: Double quote to prevent globbing and word splitting.
Or specify directory and name, in script.
– ctrl-alt-delor
Jan 24 at 8:04
1
@ctrl-alt-delor I assume by " I don't want it as hard coded" he ment he did not want that. Maybe he will clarify.
– user1133275
Jan 24 at 8:23
1
ya.. the directory and file path should not be hard coded.
– Raghav manchale
Jan 24 at 12:19
What about"$(dirname $0)/…/cSplittingLines.exe"
replace the … with the relative path.
– ctrl-alt-delor
Jan 24 at 16:13
@ctrl-alt-delor yah any relative path would work if the 2 were kept relative to eachother but the ambiguity of the question led me to the more robust solution.
– user1133275
Jan 24 at 17:35
add a comment |
Just put the exe on your $PATH (That is what it is for) (%PATH% on Windows)
mv cSplittingLines.exe /bin/
or
echo "export PATH="$PATH:/path/to/exe"" >> ~/.bashrc
Also https://www.shellcheck.net said;
SC2006: Use $(...) notation instead of legacy backticked `...`.
SC2086: Double quote to prevent globbing and word splitting.
Or specify directory and name, in script.
– ctrl-alt-delor
Jan 24 at 8:04
1
@ctrl-alt-delor I assume by " I don't want it as hard coded" he ment he did not want that. Maybe he will clarify.
– user1133275
Jan 24 at 8:23
1
ya.. the directory and file path should not be hard coded.
– Raghav manchale
Jan 24 at 12:19
What about"$(dirname $0)/…/cSplittingLines.exe"
replace the … with the relative path.
– ctrl-alt-delor
Jan 24 at 16:13
@ctrl-alt-delor yah any relative path would work if the 2 were kept relative to eachother but the ambiguity of the question led me to the more robust solution.
– user1133275
Jan 24 at 17:35
add a comment |
Just put the exe on your $PATH (That is what it is for) (%PATH% on Windows)
mv cSplittingLines.exe /bin/
or
echo "export PATH="$PATH:/path/to/exe"" >> ~/.bashrc
Also https://www.shellcheck.net said;
SC2006: Use $(...) notation instead of legacy backticked `...`.
SC2086: Double quote to prevent globbing and word splitting.
Just put the exe on your $PATH (That is what it is for) (%PATH% on Windows)
mv cSplittingLines.exe /bin/
or
echo "export PATH="$PATH:/path/to/exe"" >> ~/.bashrc
Also https://www.shellcheck.net said;
SC2006: Use $(...) notation instead of legacy backticked `...`.
SC2086: Double quote to prevent globbing and word splitting.
edited Jan 24 at 15:29
answered Jan 24 at 4:38
user1133275user1133275
3,357723
3,357723
Or specify directory and name, in script.
– ctrl-alt-delor
Jan 24 at 8:04
1
@ctrl-alt-delor I assume by " I don't want it as hard coded" he ment he did not want that. Maybe he will clarify.
– user1133275
Jan 24 at 8:23
1
ya.. the directory and file path should not be hard coded.
– Raghav manchale
Jan 24 at 12:19
What about"$(dirname $0)/…/cSplittingLines.exe"
replace the … with the relative path.
– ctrl-alt-delor
Jan 24 at 16:13
@ctrl-alt-delor yah any relative path would work if the 2 were kept relative to eachother but the ambiguity of the question led me to the more robust solution.
– user1133275
Jan 24 at 17:35
add a comment |
Or specify directory and name, in script.
– ctrl-alt-delor
Jan 24 at 8:04
1
@ctrl-alt-delor I assume by " I don't want it as hard coded" he ment he did not want that. Maybe he will clarify.
– user1133275
Jan 24 at 8:23
1
ya.. the directory and file path should not be hard coded.
– Raghav manchale
Jan 24 at 12:19
What about"$(dirname $0)/…/cSplittingLines.exe"
replace the … with the relative path.
– ctrl-alt-delor
Jan 24 at 16:13
@ctrl-alt-delor yah any relative path would work if the 2 were kept relative to eachother but the ambiguity of the question led me to the more robust solution.
– user1133275
Jan 24 at 17:35
Or specify directory and name, in script.
– ctrl-alt-delor
Jan 24 at 8:04
Or specify directory and name, in script.
– ctrl-alt-delor
Jan 24 at 8:04
1
1
@ctrl-alt-delor I assume by " I don't want it as hard coded" he ment he did not want that. Maybe he will clarify.
– user1133275
Jan 24 at 8:23
@ctrl-alt-delor I assume by " I don't want it as hard coded" he ment he did not want that. Maybe he will clarify.
– user1133275
Jan 24 at 8:23
1
1
ya.. the directory and file path should not be hard coded.
– Raghav manchale
Jan 24 at 12:19
ya.. the directory and file path should not be hard coded.
– Raghav manchale
Jan 24 at 12:19
What about
"$(dirname $0)/…/cSplittingLines.exe"
replace the … with the relative path.– ctrl-alt-delor
Jan 24 at 16:13
What about
"$(dirname $0)/…/cSplittingLines.exe"
replace the … with the relative path.– ctrl-alt-delor
Jan 24 at 16:13
@ctrl-alt-delor yah any relative path would work if the 2 were kept relative to eachother but the ambiguity of the question led me to the more robust solution.
– user1133275
Jan 24 at 17:35
@ctrl-alt-delor yah any relative path would work if the 2 were kept relative to eachother but the ambiguity of the question led me to the more robust solution.
– user1133275
Jan 24 at 17:35
add a comment |
1
You seem to have a strange mix of Windows executable and paths and Unix shell script. What is the context you're working in for that to happen?
– Michael Homer
Jan 24 at 4:16
yes,its a windows exe. We always use shell script for windows exe,which works fine,so as to pass the parameters for the exe. We have a MKS tool which also takes shell script in windows.
– Raghav manchale
Jan 24 at 4:20
3
That's probably a relevant element for you to include in the question, and anything else about the environment that might help someone to answer.
– Michael Homer
Jan 24 at 4:22
1
What is going wrong? Show us (in the question). “Something goes wrong some where”, is not useful, and will not help us spot an error.
– ctrl-alt-delor
Jan 24 at 8:00
1
Try adding an
echo about to run cSplittingLines.exe
to the script, that way you can see if it gets to this bit of the script. Alternatively turn on shell tracing.– ctrl-alt-delor
Jan 24 at 8:03