LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-08-2014, 02:03 PM   #1
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
what does this bit of BASH code do?


I am thinking about installing the player for http://wolfframalpha.com/ but they have a .sh that is pushing a Mbyte in size. While reading through the start of the script i came across a section using dd. this bothered me so Id like some help reading exactly what this bit of code is going to attempt to perform on my laptop:

Code:
MS_dd()
{
    blocks=`expr $3 / 1024`
    bytes=`expr $3 % 1024`
    dd if="$1" ibs=$2 skip=1 obs=1024 conv=sync 2> /dev/null | \
    { test $blocks -gt 0 && dd ibs=1024 obs=1024 count=$blocks ; \
      test $bytes  -gt 0 && dd ibs=1 obs=1024 count=$bytes ; } 2> /dev/null
}
Id post the entire script, but its a bit large as stated above.
 
Old 10-08-2014, 02:26 PM   #2
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,094

Rep: Reputation: 198Reputation: 198
You mean http://www.wolframalpha.com/


What exactly have you downloaded? I put 'Wolfram Alpha Player' in to Google and the first hit takes me to something which is 577MB

The function you post is using three arguments, so it should be useful to know what's being passed to it. Is this .sh all plain text? I've seen installers for stuff provided as .sh files but only small part at the start is plain text, the rest is binary stuff.
 
Old 10-08-2014, 03:00 PM   #3
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
from what little ive looked at it is all plane text.

its called CDFPlayer_9.0.1_LINUX.sh

Its a player from their web site to interact specifically with:

http://demonstrations.wolfram.com/AmdahlsLaw/

something to play with for my Computer Organization class. Just reading through and found the dd commands. i typically dont like dd commands being run if i dont know what they are writing over on my system.
 
Old 10-08-2014, 03:04 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
I think you should share the code on a pastebin: http://fpaste.org/

Or provide a link to the shell script in question.
 
Old 10-08-2014, 03:37 PM   #5
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
ill try again, but dangz gedit is failing to open the file and the yank to clipboard commands for VI are not working as they are not overwritting what i have in there now:

gg"+yG

does not seem to work.
 
Old 10-08-2014, 03:44 PM   #6
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
You can always use curl to send the file to sprunge:

Code:
cat filename | curl -F 'sprunge=<-' http://sprunge.us
It will spit out a URL you can share.

For example, here is how I sent my motd, that you can see here: http://sprunge.us/CWTY

Code:
[root@dev ~]# cat /etc/motd | curl -F 'sprunge=<-' http://sprunge.us
http://sprunge.us/CWTY

Last edited by szboardstretcher; 10-08-2014 at 03:47 PM.
 
1 members found this post helpful.
Old 10-08-2014, 03:50 PM   #7
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
nice, but sadly that site does not seem to like me:

Code:
$ cat /home/user/UCF/CDFPlayer_9.0.1_LINUX.sh | curl -F 'sprunge=<-' http://sprunge.us
curl: (56) Recv failure: Connection reset by peer
thought it might work if i first catted it into a .txt file, nope same reset by peer error.

Last edited by lleb; 10-08-2014 at 03:51 PM.
 
Old 10-08-2014, 04:55 PM   #8
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
ok, not going to happen. sorry if you need more of the code, please follow the link for the app from wolffram and download the .sh from there. after waiting well over an hour and having my laptop lock up due to gedit sucking up 100% of the CPU and RAM on a i5 with 8G ram i had to fight with the system to terminate gedit. file is just to large for the gui editor to access. if not, then ill just delete the .sh and not risk the install.
 
Old 10-08-2014, 08:37 PM   #9
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
a 597M .sh file?

Code:
curl http://dl.wolframcdn.com/0036F4/CDFPlayer/9.0.1.0/CDFPlayer_9.0.1_LINUX.sh?4ae6ee529e4e0d5967853e9e66b23dfe449a41264627f9c2ab7d4e8114291bc309c9d07415a25d7e36a9e0530efe53046ebd83355827ae20851204d85aa2d2fb0876cc0f1a51552f19.sh -O
0 597M 0 5137k 0 0 866k 0 0:11:46 0:00:05 0:11:41 1006k

Yeah, that's a real winner.
 
Old 10-09-2014, 08:20 AM   #10
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
It's a shell wrapper for installation. I've seen that before somewhere.
 
1 members found this post helpful.
Old 10-09-2014, 10:05 AM   #11
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Well I can't say exactly what the dd does, but if you notice there's no "of" argument, so it's not actually writing to anything. From what I can tell it's just dumping a file to stdout.
 
1 members found this post helpful.
Old 10-09-2014, 12:09 PM   #12
bimboleum
Member
 
Registered: Oct 2009
Posts: 111

Rep: Reputation: 23
Hi,
The dd man page implies that the dd commands running under "test" read from stdin and write to stdout. Given that the size of the shell script is 500+MB this is obviously a small shell script with a large binary attached to the end ( e.g cat <binary> >> <small shell script>). This is a standard trick for installing binaries ... e.g Virtualbox does this.

You can "see" the shell script by running "cat <big fat install package> | less". You will see the shell script part and as you scroll down, it will become obvious where the script ends and the binary begins. Typically the shell script allows you to specify options. The most useful is the "extract but do not install" option which will give you an opportunity to extract the binary and examine it (it may turn out to be a tar file) for "interesting" attributes!

As always YMMV

cheers
pete

pete hilton
saruman@ruvolo-hilton.org
 
1 members found this post helpful.
Old 10-09-2014, 02:39 PM   #13
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
ahh many thanks all for the help and info.
 
Old 10-10-2014, 05:59 AM   #14
Nogitsune
Member
 
Registered: Oct 2014
Posts: 33

Rep: Reputation: Disabled
Quote:
Originally Posted by suicidaleggroll View Post
Well I can't say exactly what the dd does, but if you notice there's no "of" argument, so it's not actually writing to anything. From what I can tell it's just dumping a file to stdout.
Yes, without 'of=' it's basic function would be similar to reading a file with 'cat' or 'less'. So in itself it's not writing over anything dangerous. Since it's inside a function, my understanding is it'll dump the results out for the caller of the function - so if you want to know where exactly the output ends up, you'd have to look for parts of the code that call the 'MD_dd' function. The first 'dd' command reads the input, and passes it to STDOUT, which in turn is directed to second block of code that has two more 'dd' commands. Those two will chop it up and pass it along to STDOUT again (which I believe then spits it out to caller of the function).

The first parameter ($1) is the name of the file or device it reads from. The second ($2) defines the size of the 'block' that it reads every cycle. conv=sync means it pads every input block with nulls to make it the size given by second parameter. The third parameter ($3) basically defines the total number of bytes it reads from the given input handle ($1).

The function will then 'chop' whatever it reads, into 1 kilobyte chunks, and spits those out to the caller of the function. Any remaining bytes that don't fill a full 1 kilobyte chunk are given out as the last chunk (which then might be smaller than 1 kilobyte).

Any possible error messages are silently discarded (directed to null device).

Last edited by Nogitsune; 10-10-2014 at 06:02 AM.
 
Old 10-10-2014, 06:33 PM   #15
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by Nogitsune View Post
Any possible error messages are silently discarded (directed to null device).
n/m. I am tired.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
running 32 bit C code .exe file using more memory to run on 64 bit machine? gajananh999 General 9 08-07-2012 08:16 AM
same fortran code but giving different results for the 32 bit vs 64 bit machine nareshUN Linux - Software 3 02-21-2012 11:33 AM
[SOLVED] Crashes in throwing exceptions if code compiled in 32 bit explicity on 64 bit system gaurav.rustagi Programming 10 01-30-2012 06:11 AM
Anyone please show me the different between the code on a 64-bit system and 32-bit ? TruongAn Programming 8 12-18-2007 08:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration