Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Bash script problems int to binary Post 303041405 by rbatte1 on Friday 22nd of November 2019 10:53:14 AM
Old 11-22-2019
One wonders why if this is not homework.

How about using what's already available and set the length like this:-
Code:
#!/bin/bash

number_in=123
length=20              # Perhaps this is ridiculous, but it proves the point.

number_out=$(echo "obase=2 ; print $number_in" | bc)
printf "%0${length}d\n" "${number_out}"



I hope that this helps,
Robin
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

int open(const char *pathname, int flags, mode_t mode) doubt...

hello everybody! I want to create a file with permissions for read, write, and execute to everybody using C, so I write this code: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(){ int fileDescriptor; fileDescriptor =... (2 Replies)
Discussion started by: csnmgeek
2 Replies

2. Shell Programming and Scripting

unzip via bash startup script problems

i have two lines in my rc.local file that are wget -O/<path>/<file>.zip url://domain.com unzip -o /<path>/<file>.zip the wget works fine, but the unzip won't work. when i copy/pase the unzip line to the prompt it works fine. i thought that maybe the unzip was running before the wget... (0 Replies)
Discussion started by: easysnowboards
0 Replies

3. Programming

Handle int listen(int sockfd, int backlog) in TCP

Hi, from the manual listen(2): listen for connections on socket - Linux man page It has a parameter called backlog and it limits the maximum length of queue of pending list. If I set backlog to 128, is it means no more than 128 packets can be handled by server? If I have three... (3 Replies)
Discussion started by: sehang
3 Replies

4. Shell Programming and Scripting

Problems editing file with awk in bash script

Hello dear users, here I have a script to manipulate .csv files that are like this originally: And I need to make a script to delete certain fields. Each field is separated with a comma. So, here is my script (at least a part of it): Field $1 is composed of a name, and then a... (5 Replies)
Discussion started by: sr00t
5 Replies

5. Shell Programming and Scripting

Execution Problems with bash script

Hello, can someone please help me to fix this script, I have a 2 files, one file has hostname information and second file has console information of the hosts in each line, I have written a script which actually reads each line in hostname file and should grep in the console file and paste the... (8 Replies)
Discussion started by: bobby320
8 Replies

6. Shell Programming and Scripting

Execution problems with BASH Shell Script

Hi I need help with my coding , first time I'm working with bash . What i must do is check if there is 3 .txt files if there is not 3 of them i must give an error code , if al three is there i must first arrange them in alphabetical order and then take the last word in al 3 of the .txt files... (1 Reply)
Discussion started by: linux newb
1 Replies

7. Shell Programming and Scripting

Bash shell script: Str(007) to int(7),increment it(8) & convert back to string(008)

Hi, I have the following requirement. There will be following text/line in a file (eg: search-build.txt) PRODUCT_VERSION="V:01.002.007.Build1234" I need to update the incremental build number (eg here 007) every time I give a build through script. I am able to search the string and get... (4 Replies)
Discussion started by: drwatson_droid
4 Replies

8. Shell Programming and Scripting

bash script error with binary operator expected.

Hello, I am not sure, where I am missing in the scirpt, I am trying to grep few users from /etc/passwd file and if exists, I added line to echo as user exist, if not create it. #!/bin/bash for vid in v707 z307 z496 z163 z292 ; do if then echo " $vid User exists " else ... (2 Replies)
Discussion started by: bobby320
2 Replies

9. Shell Programming and Scripting

Bash script having variable substitution problems

Hi I am setting the variables like this : setenv MODULE1 modem5__3 setenv MODULE2 modem5__2 setenv MODULE3 modem_ctrl_1_1 setenv MODULE4 modem_1_0 setenv COUNT 10 I am having a bash script as shown below ################################################ #!/bin/bash for ((... (5 Replies)
Discussion started by: kshitij
5 Replies

10. Shell Programming and Scripting

sed problems - Bash Script

Hi I keep getting the following error sed: -e expression #1, char 32: unterminated `s' command sed: -e expression #1, char 35: unterminated `s' command sed: -e expression #1, char 35: unterminated `s' command whenever I use the following bash script #! /bin/bash... (2 Replies)
Discussion started by: spbr
2 Replies
XMMS2-ET(1)						      General Commands Manual						       XMMS2-ET(1)

NAME
xmms2-et - transmits an anonymous informative packet to the XMMS2 team on each song change SYNOPSIS
xmms2-et DESCRIPTION
XMMS2 is a redesign of the XMMS (http://www.xmms.org) music player. It features a client-server model, allowing multiple (even simultane- ous!) user interfaces, both textual and graphical. All common audio formats are supported using plugins. On top of this, there is a flexi- ble media library to organize your music. xmms2-et is the ET Phone Home Client for XMMS2. xmms2-et is designed to transmit a packet of information to the XMMS2 team whenever a new song is played. The packet is anonymous and does not contain metadata about the song being played. The specifics of what data is transmit- ted to the XMMS2 team can be found in the ET PACKET section of this manual page. xmms2-et is used for release engineering by the XMMS2 team. During a release cycle, the usage of various plugins, operating systems, and XMMS2 components is collected from data transmitted by the xmms2-et client. A release is made when sufficient testing has occured as deter- mined by the number of related xmms2-et packets that the XMMS2 team has received. ET PACKET
The following data is transmitted with every packet transmitted by xmms2-et: XMMS2-ET status Begins XMMS2-ET packets; status gives a descriptive message denoting what this packet is about. (e.g. Clean shutdown, Unclean shut- down, New media) version=version contains the version of the XMMS2 daemon system=os contains the name and release of the operating system on which xmms2d is running output=output_plugin contains the output plugin being used to playback audio by xmms2d starttime=start_time contains the time at which the xmms2-et client was started uptime=xmms2d_uptime contains the uptime of the xmms2-et client playlistloads=times contains the number of times a playlist has been loaded from the Media Library mlibresolves=times contains the number of times that metadata has been resolved for media in the Media Library The following data is different for each song being played: decoder=plugin contains the decoder plugin used to playback the last played song transport=plugin contains the transport plugin used to read the last played song samplefmt:in=in_fmt contains the sample format of the original audio file of the last played song samplefmt:out=out_fmt contains the sample format that was sent to the output plugin for the last played song samplerate:in=in_rate contains the sample rate of the original audio file of the last played song samplerate:out=out_rate contains the sample rate that was sent to the output plugin for the last played song channels:in=number_in contains the number of channels of the original audio file of the last played song channels:out=number_out contains the number of channels that were sent to the output plugin for the last played song ENVIRONMENTAL VARIABLES
XMMS_PATH The URL path to xmms2d. See IPC SOCKET in xmms2d(8) for details of possible values for this variable SEE ALSO
xmms2(1), xmms2d(8), http://xmms2.xmms.org HISTORY
The XMMS2 Project was started by Tobias Rundstrom and Anders Gustafsson. It is developed with their lead by a small group of contributers from all over the world. AUTHOR
This manual page was written by Alexander Botero-Lowry <alex@foxybanana.com> XMMS2-ET(1)
All times are GMT -4. The time now is 02:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy