Author Topic: How to run shell script  (Read 22379 times)

Offline binnyshah

  • Multiple posting newcomer
  • *
  • Posts: 22
How to run shell script
« on: July 13, 2010, 12:44:03 pm »
Hi,
 I need to run a shell script before compiling my code using code blocks.
Also need to run a make command.
Please guide.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to run shell script
« Reply #1 on: July 13, 2010, 12:59:34 pm »
What do you want to achieve, exactly?

You can run shell scripts from pre/post build steps (Project->Build options->Pre/Post build steps).
Also C::B can use make to build your project if it is makefile based ( Project -> Properties -> There is somewhere a checkbox for "Makefile project")
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline binnyshah

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: How to run shell script
« Reply #2 on: July 13, 2010, 08:15:26 pm »
I tried adding the below to Project->Build options->Pre/Post build steps
$sh ..\..\..\..\..\..\msys\1.0\home\admin\vlc\extras\package\win32\configure-msys.sh

I got the following error
Running target pre-build steps
 ..\..\..\..\..\..\msys\1.0\home\admin\vlc\extras\package\win32\configure-msys.sh
Execution of ' ..\..\..\..\..\..\msys\1.0\home\admin\vlc\extras\package\win32\configure-msys.sh' in 'C:\Documents and Settings\admin\Desktop\Binny Work\CodeBlocks PRj\Sample' failed.
Nothing to be done.

Get a similar error even when tried with absolute path..

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to run shell script
« Reply #3 on: July 13, 2010, 11:48:45 pm »
Is this on windows? Probably you have to use batch files....
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline reckless

  • Regular
  • ***
  • Posts: 338
Re: How to run shell script
« Reply #4 on: July 14, 2010, 03:28:22 am »
add the bin dir from msys to additional paths so it picks up sh.exe.

and put your project someplace with a short name msys sh.exe does not like windows long names in the least. i suggest C:\projects\your-project (avoid spaces in the project name).

and aye might be easier with a batch file.



Offline binnyshah

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: How to run shell script
« Reply #5 on: July 14, 2010, 12:13:41 pm »
yes it is windows based...but is there no way to run shell script directly from code::blocks?
@reckless::I dint quite understand your suggestion...can u pls guide in detail if that is fine with you

Offline reckless

  • Regular
  • ***
  • Posts: 338
Re: How to run shell script
« Reply #6 on: July 14, 2010, 01:08:41 pm »
i can try (not very good at explaining).

first of you need msys from mingw's site. its a small unix shell environment, install it to the default location c:\msys\1.0 now open up codeblocks hit settings -> compiler and debugger and go to the tab named toolchain executables. besides the program files tab theres another tab called additional paths, open that.

hit the button named add in that tab a small window called add directory will open, theres a small button in it with ... 3 dots hit that one, (its the same as browse) and point it at C:\msys\1.0\bin voila you can now access sh.exe.

if the project is allready setup for using that shell script things should work now, if not you may have to tinker a bit with settings to tell it to run sh.exe on that script.

hope i was clear enough.

Offline binnyshah

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: How to run shell script
« Reply #7 on: July 15, 2010, 11:40:23 am »
Thank you sooo much..I could finally run the shell script..
But alas...with an error..
The shell script which runs well normally gives the below error from code-blocks
line 7: --without-contrib: command not found

pls find below the code:
if [ -z $CONTRIBS ]
then
   CONTRIBS=/usr/win32
fi

      $CONFIG \
      --without-contrib \
      --enable-update-check \
      --enable-lua \
      --enable-faad \
      --enable-flac \
      --enable-theora \
      --enable-twolame \
      --enable-quicktime \
      --enable-real \
      --enable-avcodec  --enable-merge-ffmpeg \
      --enable-dca \
      --enable-mpc \
      --enable-libass \
      --enable-x264 \
      --enable-schroedinger \
      --enable-realrtsp \
      --enable-live555 --with-live555-tree=$CONTRIBS/live.com \
      --enable-dvdread --with-dvdnav-config-path=$CONTRIBS/bin \
      --enable-shout \
      --enable-goom \
      --enable-caca \
      --enable-portaudio \
      --enable-sdl --with-sdl-config-path=$CONTRIBS/bin \
      --enable-qt4 \
      --enable-mozilla --with-mozilla-sdk-path=$CONTRIBS/gecko-sdk \
      --enable-activex \
      --enable-sse --enable-mmx \
      --enable-libcddb \
      --enable-zvbi --disable-telx \
      --disable-dvb \
      --disable-sqlite \
      --enable-peflags


Offline reckless

  • Regular
  • ***
  • Posts: 338
Re: How to run shell script
« Reply #8 on: July 16, 2010, 11:08:41 am »
ah i see its for the mozilla plugin.

now the damn thing is that you will probably have to use the mozilla sdk to make that part working.

the mozilla sdk uses a special version of msys and normally uses msvc as the compiler as opposed to the normal msys which uses mingw.

unfortunatly i newer dabbled in setting it up so im a bit blank on how to help with that.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: How to run shell script
« Reply #9 on: July 16, 2010, 06:02:14 pm »
As was suggested before, use a windows batch file.

Get the code to work using a windows batch file from the windows cmd prompt. Then call the batch file inside Code::Blocks.

This should allow to to figure out if batch file is wrong or Code::Blocks is causing problem.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline binnyshah

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: How to run shell script
« Reply #10 on: July 19, 2010, 12:50:29 pm »
Thank you all guys....finally I have been able to run both the shell scripts...
Also in Project properties I have set path for customized makefile..

I get build message as build complete...but while trying to run...I get the message:
This project has not been built yet...do you want to build it...

Why so?

Offline reckless

  • Regular
  • ***
  • Posts: 338
Re: How to run shell script
« Reply #11 on: July 19, 2010, 09:10:26 pm »
mainly because shellscripts are not an integral part of the ide :) its more like a preprocessining stage
where you use an external tool to handle some stuff the ide cant handle itself.

see it a bit like the gas2masm conversion in quake. quakes assembler code is gnu style (first version was built with djgpp another posix based compiler) gas2masm converts gnu style assembly code to something microsofts masm compiler understands. gas2masm in it self is not part of any specific toolchain, but only used for this specific task.

Offline binnyshah

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: How to run shell script
« Reply #12 on: July 20, 2010, 08:24:19 pm »
after running the shell script I have given the make command...which gets executed as well...

In build messages tab,i get the last message as
Build Successful
0 Errors 18 warnings


But in build log i get
Using makefile: Makefile
mingw32-make.exe: *** No rule to make target `Debug'.  Stop.
Process terminated with status 2 (12 minutes, 42 seconds)
0 errors, 18 warnings

Please guide

Offline binnyshah

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: How to run shell script
« Reply #13 on: July 20, 2010, 09:12:48 pm »
Hey...got this resolved...
I had to include mingw\bin in additional paths....
build is still in progress , but I can see the .exe file has been created....
Wish me luck :)

Offline binnyshah

  • Multiple posting newcomer
  • *
  • Posts: 22
Re: How to run shell script
« Reply #14 on: July 20, 2010, 09:15:13 pm »
Exe has been created...
But while trying to run I get the below error:

Checking for existence: C:\msys\1.0\home\admin\vlc\vlc.exe
Executing: "C:\Program Files\CodeBlocks/cb_console_runner.exe" "C:\msys\1.0\home\admin\vlc\vlc.exe"  (in C:\Documents and Settings\admin\Desktop\Binny Work\CodeBlocks PRj\Sample\.)
Process terminated with status -1073741510 (0 minutes, 11 seconds)

I shall post this in a seperate thread as well to keep track